This support text is compiled from the original forum at www.civfanatics.net

November 1, 2004

This support file is not part of the original distribution. It is being offered as supplemental material to help
provide support to installation support

I've made patch for colonization that fixes combat streak bug. You can download it there http://sixdays.narod.ru/canalization.zip

1. Patch works for DOS and Win98 only.
2. To run patch under winXP launch "cmd" process in directory where colonization is placed and then type "start.bat". But sometimes the game freezes under winXP, so it's better to play under dos.

I meant straight DOS, so use boot floppy or boot CD-ROM. But under DOS you have to launch "canali~1" and then "viceroy" because of short names of files (I forgot about it when was creating patch). 

[Other issues: DosBox not supported. Windows 95, ME, 2000 not supported. Feel free to find "work arounds" for this patch and post them at CivFanatics or contact the author to contribute but not for 
support]

============================================================================
Technical Aspects for the "Combat Streak Bug"

Hi there! 

Combat 'streak' bug - during a given turn, you will win every single battle (at least those that you initiate...I'm not sure about battles the AI starts) *or* you will lose every single battle. Then, moving 
on to the next turn 'resets' the streak, but a new win or loss streak will start right up on the next turn. \
This bug is a gamebreaker because after the first battle of any turn, you can predict the outcome of all other battles with 100% accuracy.

I want to tell you about how battles work in colonization. I knew it when I was studing cheat mode. I believe you'll be interested it. 

So, run colonization, choose spain at viceroy level (i'll explain below why) and turn cheat mode on (alt - WIN). Reveal all the map. Create militia close to indian village. Attack indian village.

Let's see:
Combat analyses

-----------------------------------------------------
Soldiers 2
Attack bonus +50%
Spain bonus +50%

Soldiers +36 (*)
(following string contains a number, for example: +40) (**)

------------------------------------------------------
Braves 1
Village +50%

Braves +6 (***)
+42 (****)

How do you think, what numbers mean? Listen the answer.

(*) is attack value for random generator.
> Soldiers 2
Soldiers' strength is 2.
2 * K = 2 * 8 = 16
> Attack bonus +50%
16 * bonus1 = 16 * 1.5 = 24
> Spain bonus +50%
24 * bonus2 = 24 * 1.5 = 36

In short,
Attack = Strength * K * bonus1 * bonus2 *...
where K = 8

Attack = 2 * 8 * 1.5 * 1.5 = 36

As consequence, two bonuses +50% better than one +100%

(***) is defence value for random generator. Algorithm is the same.
> Braves 1
Braves' strength is 1.
1 * K = 1 * 8 = 8
> Village +50%
8 * bonus1 = 8 * 1.5 = 12

Attention! There's hidden *bonus* -50% if unit's strength is one and it hasn't got rifles and its opponent has.
If you attack indian braves or foreign colonists with your scout then braves or colonists won't get rifle_bonus -50%
Artillery vs. unarmed unit will cause appearance of rifle_bonus to unarmed unit.


Defence = (1 * 8 * 1.5) * rifle_bonus = 12 * 0.5 = 6

(****) is sum of (*) and (***)
Sum = Attack + Defence = 36 + 6 = 42

Next, number (**) is random value from 1 to Sum. Let's call it Result.

If 1 <= Result <= Attack then attack is successful
If Attack < Result <= Defence then attack isn't succesfull

So, if Result = +40 then our militia demote to colonists status. If Result = +15 then our militia win the battle.


This combat system works for ships as well.

If you choose another level, governor or easer, you'll get some bonuses to combat.
Governor: +1 to your final attack/defence
Conquistador: +2 to your final attack/defence

Easer levels will get you even bigger K while your opponents won't.


I run my DOS colonization version under winXP and I have such a bug:
Result (**) in battles has to be RANDOM VALUE. Instead, this value is increasing consecutive from battle to battle and resets when it reaches Sum.

For example, my militia attack braves and Result is +5. Result in next battle of this turn will be +5, +6 or +7. Next - +6, +7, +8 or +9. And so on. So, there'll be line of WONS and then line of LOSES. And this is explanation of question:

The Solution ***********************************************************************************************************

So, I know how to get rid of Random Generator Bug.

Do following.
1. Open viceroy.exe in your hex-editor.
2. Find such bytes: A3 EE 28 C7 06
3. Replace A3 with 5D, and EE with CB, so you get 5D CB 28 C7 06
4. Bug was removed!

The problem of Random Generator Bug was caused by too frequent calling randomize () that is syncronization of random seed with current time counter (0040:006C). If calling of randomize function is more frequent than time counter changes then random function returns almost the same value.

The Discussion*********************************************************************************************************

First, I knew how battles work using cheat mode. Then I found out that results of battles depends on time, so 2 battles, fulfilled close to each other, had the same result ("random" value). But if you wait some seconds between battles last result will increase slightly. What does it mean? The game often synchronize its random seed with timer (by function randomize ()). But this's real bug because game must call randomize just once. So, the task was to take syncronization out from program code.

It's common known that DOS timer located at 40:6c (long word). SoftICE allows to trace reading from given address (bpm 40:6c r) and it wasn't problem to find out which instructions read timer. There was something like that:

random_seed = get_timer ();
random_seed = generate_random_value (random_seed);

Random function (generate_random_value) returns "random" value depending on random seed, and for 2 equal random seeds "random" values will be equal as well. Let's skip this instructions!
A3 EE 28 C7 06 - these are bytes of original instructions.
5D CB 28 C7 06 - these are our overpatching.

Don't think I know this instruction's code by heart, I just used softICE's possibility to assemble code in assembler language and then I wrote down obtained bytes.

But it wasn't end. Without randomize () the game worked better, but random generator was bad anyway. So I decided to replace game's random generator by my generator.

There's one good program, ArtMoney, it allows to find addresses in memory. I found address where battles result is written. Then I wanted to determine which code instructions write to this address. Unpleasant surprise - the address is part of program stack and too many different instructions write to this address. To solve this problem I defined breakpoint with such condition: writing to found address when ax is equal to 80h. 80h - attack value of attacking frigate. Then I attacked enemy frigate with my frigate. Bingo! Breakpoint executed and I found battle procedure. I checked it and found such instructions:

push ax
push 01
call ....:....

This's calling of function which takes two arguments: 1 and ax. ax keeps (attack+defence) value, so this function returns random value from 1 to ax.

Write own random generator's program and make it resident. Change instruction to call your own random function. Go to drink beer 

There was many indescribable problems and devastating situations, but aim was reached.

Besides, I used cracked version of SoftICE. I know you don't like illegal programs but I can't buy such kind of stuff every time I want to have fun.