From a94be38288e1e0cb0ad0b0244432b59a7ecda984 Mon Sep 17 00:00:00 2001 From: ariclone <> Date: Mon, 31 Jul 2000 18:41:36 +0000 Subject: [PATCH] Finished Custom Game 'Opponents' selection (reduce only!) --- src/include/pud.h | 8 ++++++++ src/include/unittype.h | 14 +------------- src/stratagus/player.cpp | 1 + src/stratagus/pud.cpp | 34 +++++++++++++++++++++++----------- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/include/pud.h b/src/include/pud.h index 3c364af00..d3ded2bfb 100644 --- a/src/include/pud.h +++ b/src/include/pud.h @@ -62,6 +62,14 @@ #define MapActionRocks 0xFFFD /// rocks on map #define MapActionForest 0xFFFE /// forest on map +// These are hard-coded PUD internals (and, as such, belong here!) +#define WC_UnitPeasant 0x02 /// Human Peasant +#define WC_UnitPeon 0x03 /// Orc Peon +#define WC_UnitGoldMine 0x5C /// Goldmine +#define WC_UnitOilPatch 0x5D /// Oilpatch +#define WC_StartLocationHuman 0x5E /// Start location Human +#define WC_StartLocationOrc 0x5F /// Start location Orc + /*---------------------------------------------------------------------------- -- Declarations ----------------------------------------------------------------------------*/ diff --git a/src/include/unittype.h b/src/include/unittype.h index 8d2810938..c1206f44c 100644 --- a/src/include/unittype.h +++ b/src/include/unittype.h @@ -200,21 +200,9 @@ struct _unit_type_ { }; /// How many unit types are currently supported. + /// FIXME: ARI: should be dynamic (ccl..) #define UnitTypeInternalMax 0x74 - /// Human Peasant (for pud use only) -#define WC_UnitPeasant 0x02 - /// Orc Peon (for pud use only) -#define WC_UnitPeon 0x03 - /// Goldmine (for pud use only) -#define WC_UnitGoldMine 0x5C - /// Oilpatch (for pud use only) -#define WC_UnitOilPatch 0x5D - /// Start location unit type number in puds. -#define WC_StartLocationHuman 0x5E - /// Start location unit type number in puds. -#define WC_StartLocationOrc 0x5F - /*---------------------------------------------------------------------------- -- Variables ----------------------------------------------------------------------------*/ diff --git a/src/stratagus/player.cpp b/src/stratagus/player.cpp index b17886f40..db3f88866 100644 --- a/src/stratagus/player.cpp +++ b/src/stratagus/player.cpp @@ -92,6 +92,7 @@ global void CreatePlayer(char* name,int type) // Allocate memory for the "list" of this player's units. // FIXME: brutal way, as we won't need MAX_UNITS for this player... + // FIXME: ARI: is this needed for 'PlayerNobody' ?? if( !(player->Units=(Unit**)calloc(MAX_UNITS,sizeof(Unit*))) ) { DebugLevel0("Not enough memory to create player %d.\n",NumPlayers); return; diff --git a/src/stratagus/pud.cpp b/src/stratagus/pud.cpp index 76594efe0..c136dfaae 100644 --- a/src/stratagus/pud.cpp +++ b/src/stratagus/pud.cpp @@ -714,6 +714,7 @@ global void LoadPud(const char* pud,WorldMap* map) char buf[1024]; int width; int height; + int aiopps; if( !(input=CLopen(pud)) ) { fprintf(stderr,"Try ./path/name\n"); @@ -739,7 +740,7 @@ global void LoadPud(const char* pud,WorldMap* map) exit(-1); } - width=height=0; + aiopps=width=height=0; // // Parse all sections. @@ -785,6 +786,15 @@ global void LoadPud(const char* pud,WorldMap* map) for( i=0; i<16; ++i ) { p=PudReadByte(input); + if (GameSettings.Opponents != SettingsPresetMapDefault) { + if (p == PlayerComputer) { + if (aiopps < GameSettings.Opponents) { + aiopps++; + } else { + p = PlayerNobody; + } + } + } CreatePlayer("Computer",p); } continue; @@ -1137,7 +1147,7 @@ global void LoadPud(const char* pud,WorldMap* map) Players[o].X=MapOffsetX+x; Players[o].Y=MapOffsetY+y; - if (GameSettings.NumUnits == SettingsNumUnits1) { + if (GameSettings.NumUnits == SettingsNumUnits1 && Players[o].Type != PlayerNobody) { if (t == WC_StartLocationHuman) { t = WC_UnitPeasant; } else { @@ -1146,7 +1156,7 @@ global void LoadPud(const char* pud,WorldMap* map) v = 1; goto pawn; } - } else { + } else { if (GameSettings.NumUnits == SettingsNumUnitsMapDefault || t == WC_UnitGoldMine || t == WC_UnitOilPatch) { pawn: @@ -1158,17 +1168,19 @@ pawn: if (s == PlayerRaceOrc && (t & 1) == 0) { t++; } - // FIXME: This is hard-coded WAR2 ... also: support more races? + // FIXME: ARI: This is hard-coded WAR2 ... also: support more races? } } - unit=MakeUnitAndPlace(MapOffsetX+x,MapOffsetY+y - ,UnitTypeByWcNum(t),&Players[o]); - if( unit->Type->GoldMine || unit->Type->OilPatch ) { - unit->Value=v*2500; - } else { - // FIXME: active/inactive AI units!! + if (Players[o].Type != PlayerNobody) { + unit=MakeUnitAndPlace(MapOffsetX+x,MapOffsetY+y + ,UnitTypeByWcNum(t),&Players[o]); + if( unit->Type->GoldMine || unit->Type->OilPatch ) { + unit->Value=v*2500; + } else { + // FIXME: active/inactive AI units!! + } + UpdateForNewUnit(unit,0); } - UpdateForNewUnit(unit,0); } }