CivOne - An Open Source remake of Civilization 1

Thanks a lot! I will try this out tonight.

I've got river/poles generation working now, so my Civ clone generates complete Civilization-like maps.

Also, I think I figured out the river/coast animation, so I might get that working in the next version too.
 
I haven't looked at how CIV.EXE does it but looking at ter257.pic this is how *think* it goes. In pseudo code:
Code:
// Build a bit mask of all 8 surrounding tiles, setting the bit if the tile is not an 
// ocean tile. Starting with the tile to the left as the least significant bit and 
// going clockwise
bitmask = 
  (leftTile != ocean ? 1 : 0)|
  (topLeftTile != ocean ? 2 : 0)|
  (topTile != ocean ? 4 : 0)|
  (topRightTile != ocean ? 8 : 0)|
  (rightTile != ocean ? 16 : 0)|
  (botRightTile != ocean ? 32 : 0)|
  (botTile != ocean ? 64 : 0)|
  (botLeftTile != ocean ? 128 : 0);

if (bitmask == 0) {
  // This means the tile is surrounded by ocean, so simply draw the ocean tile with
  // no coast

  // screen_x, screen_y, sprite_x, sprite_y, width, height
  drawImage(0, 0, 0, 176, 16, 16); 
} else {
  // There are at least one surrounding tile that is not ocean, so we need to render
  // coast. We divide the tile into four 8x8 subtiles and for each of these we want 
  // a 3 bit bitmask of the surrounding tiles. We do this by looking at the 3 least 
  // significant bits for the top left subtile and shift the mask to the right as we 
  // are going around the tile. This way we are "rotating" our bitmask. The result 
  // are our x offsets into ter257.pic
  topLeftSubtileOffset = bitmask&7;
  topRightSubtileOffset = (bitmask>>2)&7);
  bottomRightSubtileOffset = (bitmask>>4)&7);
  bottomLeftSubtileOffset = (bitmask>>6)&7)|((bitmask&1)<<2);

  // screen_x, screen_y, sprite_x, sprite_y, width, height
  drawImage(0, 0, topLeftSubtileOffset<<4, 176, 8, 8);
  drawImage(8, 0, (topRightSubtileOffset<<4)+8, 176, 8, 8);
  drawImage(8, 8, (bottomRightSubtileOffset<<4)+8, 176+8, 8, 8);
  drawImage(0, 8, bottomLeftSubtileOffset<<4, 176+8, 8, 8);
}

Perhaps Darkpanda can verify that this is correct? The algorithm for determining if a tile should be replaced with the animated shore is unknown to me.

Can't tell you if it's right, but you can cross-check with the ported code in JCivED, almost transliterated from CIV.EXE assembly: http://sourceforge.net/p/jcived/code/HEAD/tree/branches/dev/src/dd/civ/logic/port/OriginalCivLogic.java (line 1908)

I didn't go into the details but it seems close to what you have deciphered yourself, good job!

Also, all animations in CIV are based on palette cycling, so there aren't different sprites for animation.
 
I can confirm, this code is correct. Thanks! :goodjob: I've got correct coast lines implemented now. :)
There's still some half-finished ends to tie up, so I don't think I'll release today.
 
Hey question for ya. Is it in your plans (way in the future probably) to make the savegames compatible for dos as well as for windows? Just curious.
 
I've been thinking about that... and yes, I want it to be able to compatible with the DOS version savegames.
However... there will be a modding API and once you activate any mods that add or remove terrain/units/advances/wonders/governments, or that has a different map size, we will need a new file format that is no longer compatible.

Vanilla, this clone will load and save in the original file format though.
 
Woohoo! I've got fog of war semi-working. :D
 

Attachments

  • fog.png
    fog.png
    21.9 KB · Views: 568
I've released version 0.03a, a bit later than I planned... but there's more features than I initially planned as well. Download here: https://mega.co.nz/#!kcFlVara!Qdi0ZmfsADxgxUGzC-nIJVye0r246ZqHFdoDJmMob9E

(or download from attachment in original post)

Here's the change log:
  • Changed the project to .NET 4.0
  • Fixed a bug where the Windows control box was opened when pressing 'F10'
  • Fixed graphics issues on scale x1
  • Fixed graphics slowness that increased when the scale was higher
  • Fixed a bug, causing a vertical line on large fonts
  • Fixed a bug where the mouse cursor was off by 1 pixel
  • Implemented the original world generation algorithm
  • Implemented Play on EARTH
  • Intro screen with credits (no mouse controls yet)
  • Fade in/out in new game intro
  • Fog of war implemented
  • Minimap implemented
  • All civilization advances implemented
  • Units require advances, go obselete
  • Implemented civilopedia for advances
  • Added buttons to city manager (mouse controls not yet functional)
  • Added mouse controls for the New Game menu
  • Added Customize World menu
  • Added City Status screen (press 'F1')
  • Added Military status/losses screens (press 'F2')
  • Added Intelligence Report screen (press 'F3')
  • Added Attitude Survey screen (press 'F4')
  • Added Trade Report screen (press 'F5')
  • Added Science Report screen (press 'F6')
  • Added Civilization Score screen (press 'F9')
  • Added Patch #3: Instant complete production/science (SHIFT+B)
  • Added Patch #4: Faster unit movement (skip frames)
  • Added Patch #5: Reveal entire world/all unit movement

Mouse controls are not working in many menus/screens. Please use your cursor keys for now.
I eagerly await your experiences/bug reports/etc.

In the next version I will not add many new features... but it will be the first open source release on github.
Now, I'm off... adding GPL headers to all files and documenting the code. :D
 
Is there no yet any way to choose which tiles to work in city? I think this should be high priority if you want some play testing to happen.
 
Is there no yet any way to choose which tiles to work in city? I think this should be high priority if you want some play testing to happen.

I will, at least, add that feature to the next version... as well as all other mouse actions that are not working at the moment.

Edit:
I've implement a cheat patch in version 0.03a. If you enable this patch, you can instantly complete a discovery by pressing CTR+B in the Science screen (F6) and you can instantly complete a unit in the City manager. This should help with testing some of the finished gameplay elements.
 
I was wondering, is there a way to determine which buildings are built when you are on auto production? It would be nice to eventually have a popup menu to select and deselect the buildings that you want you build.

One more thing...
Can you give the option of choosing whether the units found by huts are assigned to the nearest city or not? I like the idea of not having to be dependent on a city for upkeep...

Well another thing or two.
Is it possible to allow cities to span across the edges of the map? Can we allow units to cross all the edges of the map (like up and down)? This would add to the overall gameplay and strategy in my opinion.
 
One more thing...
Can you give the option of choosing whether the units found by huts are assigned to the nearest city or not? I like the idea of not having to be dependent on a city for upkeep...
 
Woohoo! My user account works again. :D
I'm about 60% done with documenting the code. Expect the open sourced version in about a week.

kirkham7: there will be a modding API making all these things possible through plugins. I will, however, first create a clone of the original game, with the same rules and flaws.
 
I'm about 60% done with documenting the code. Expect the open sourced version in about a week.

Documenting code is a waste of time! :D

Anyway, looking forward to browsing the code and contributing here and there
 
Documenting code is a waste of time!

I agree with this. :)

One thing that interest me is to hack in a multiplayer functionality. And trying to create some sort of AI. And maybe the ultimate WW2 scenario on huge map.:scan:

Can't wait!
 
Imagine the possibilities of more than 7 civilizations with a proper AI... That sounds like a challenge!
I'd like to make a scenario of ground units only. That could work out nicely with a world war scenario. :)
 
Civilization (1) is by far my most favourite game. :D
Please let me know what you think.

Nice. Unfortunately I lost the original discs in one of my house moving endeavours and The Chronicles of Civilization box did not include Civ1, as advertized, but Civnet. So I won't be able to play this. But good job so far! :goodjob:
 
Lol, no idea why they did that. Anyways, there are several floating around on ebay of the original game if you are interested.
 
Top Bottom