Started to make races more configurable
This commit is contained in:
parent
e39d911e2c
commit
48c45d548c
6 changed files with 41 additions and 43 deletions
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
/**@name ai.c - The computer player AI main file. */
|
||||
//
|
||||
// (c) Copyright 1998-2002 by Lutz Sammer
|
||||
// (c) Copyright 1998-2003 by Lutz Sammer
|
||||
//
|
||||
// FreeCraft is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
|
@ -219,18 +219,20 @@ local PlayerAi Ais[PlayerMax]; /// storage for all players
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Chooses which Race the building/unit needs to be.
|
||||
** Chooses which Race the building/unit needs to be.
|
||||
** FIXME: this is soon broken, must find better way!!!!
|
||||
*/
|
||||
local int AiChooseRace(int type)
|
||||
{
|
||||
if (AiPlayer->Player->Race == PlayerRaceHuman) {
|
||||
if (type % 2 == 0)
|
||||
if (AiPlayer->Player->Race == PlayerRaces.Race[0]) {
|
||||
if (type % 2 == 0) {
|
||||
return type;
|
||||
}
|
||||
return type - 1;
|
||||
}
|
||||
if (type % 2 == 1)
|
||||
if (type % 2 == 1) {
|
||||
return type;
|
||||
}
|
||||
return type + 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ local void DrawUnitIcons(void)
|
|||
y += 18 * 1 + 4;
|
||||
if( SelectedPlayer != -1 ) {
|
||||
i=sprintf(buf,"Plyr %d %s ",SelectedPlayer,
|
||||
RaceWcNames[TheMap.Info->PlayerSide[SelectedPlayer]]);
|
||||
PlayerRaces.Name[TheMap.Info->PlayerSide[SelectedPlayer]]);
|
||||
// Players[SelectedPlayer].RaceName);
|
||||
|
||||
switch( TheMap.Info->PlayerType[SelectedPlayer] ) {
|
||||
|
|
|
@ -970,16 +970,16 @@ local int GameStatsDrawFunc(int frame)
|
|||
char** ranks;
|
||||
int* scores;
|
||||
|
||||
ranks = NULL; /* .. -Wuninitialized .. */
|
||||
ranks = NULL;
|
||||
scores = NULL;
|
||||
for( i=0; RaceWcNames[i]; ++i ) {
|
||||
if( !strcmp(RaceWcNames[i],ThisPlayer->RaceName) ) {
|
||||
for( i=0; i<PlayerRaces.Count; ++i ) {
|
||||
if( !strcmp(PlayerRaces.Name[i],ThisPlayer->RaceName) ) {
|
||||
ranks=Ranks[i].Ranks;
|
||||
scores=Ranks[i].Scores;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DebugCheck( !RaceWcNames[i] );
|
||||
DebugCheck( i==PlayerRaces.Count );
|
||||
|
||||
rank=ranks[0];
|
||||
i=0;
|
||||
|
@ -1488,13 +1488,13 @@ local SCM CclDefineRanks(SCM list)
|
|||
|
||||
rank=NULL;
|
||||
race=get_c_string(gh_car(list));
|
||||
for( i=0; RaceWcNames[i]; ++i ) {
|
||||
if( !strcmp(RaceWcNames[i], race) ) {
|
||||
for( i=0; i<PlayerRaces.Count; ++i ) {
|
||||
if( !strcmp(PlayerRaces.Name[i], race) ) {
|
||||
rank=&Ranks[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !RaceWcNames[i] ) {
|
||||
if( i==PlayerRaces.Count ) {
|
||||
fprintf(stderr,"define-ranks: Invalid race name: %s\n",race);
|
||||
ExitFatal(-1);
|
||||
}
|
||||
|
|
|
@ -289,9 +289,9 @@ typedef struct _menus_ {
|
|||
** Struct which specifies the buttons gfx
|
||||
*/
|
||||
typedef struct _menu_graphics_ {
|
||||
char* File[PlayerMaxRaces]; /// resource filename one for each race
|
||||
int Width[PlayerMaxRaces]; /// Width of button
|
||||
int Height[PlayerMaxRaces]; /// Height of button
|
||||
char* File[MAX_RACES]; /// resource filename one for each race
|
||||
int Width[MAX_RACES]; /// Width of button
|
||||
int Height[MAX_RACES]; /// Height of button
|
||||
Graphic* Sprite; /// sprite : FILLED
|
||||
} MenuGraphics;
|
||||
|
||||
|
|
|
@ -79,9 +79,8 @@
|
|||
** Player::Race
|
||||
**
|
||||
** Race number of the player. This field is setup from the level
|
||||
** (PUD). This number is mapped with #RaceWcNames to the symbolic
|
||||
** (PUD). This number is mapped with #PlayerRaces to the symbolic
|
||||
** name Player::RaceName.
|
||||
** @see #PlayerRaces.
|
||||
**
|
||||
** Player::AiNum
|
||||
**
|
||||
|
@ -358,18 +357,24 @@ struct _player_ {
|
|||
};
|
||||
|
||||
/**
|
||||
** Races for the player (must fit to PUD!)
|
||||
** Mapped with #RaceWcNames to a symbolic name, which will be used in
|
||||
** Races for the player
|
||||
** Mapped with #PlayerRaces to a symbolic name, which will be used in
|
||||
** the future.
|
||||
**
|
||||
** @note FIXME: This and the use MUST be removed to allow more races.
|
||||
*/
|
||||
enum PlayerRaces {
|
||||
#define MAX_RACES 8
|
||||
typedef struct _player_race_ {
|
||||
int Race[MAX_RACES]; /// race number
|
||||
char Visible[MAX_RACES]; /// race should be visible in pulldown
|
||||
char* Name[MAX_RACES]; /// race names
|
||||
char* Display[MAX_RACES]; /// text to display in pulldown
|
||||
int Count; /// number of races
|
||||
} PlayerRace;
|
||||
|
||||
|
||||
enum PlayerRacesOld {
|
||||
PlayerRaceHuman =0, /// belongs to human
|
||||
PlayerRaceOrc =1, /// belongs to orc
|
||||
PlayerRaceNeutral =2, /// belongs to none
|
||||
|
||||
PlayerMaxRaces =3 /// maximal races supported
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -455,12 +460,15 @@ extern int NoRescueCheck; /// Disable rescue check
|
|||
extern int PlayerColors[PlayerMax]; /// Player colors
|
||||
extern char* PlayerColorNames[PlayerMax]; /// Player color names
|
||||
|
||||
extern char** RaceWcNames; /// pud original -> internal
|
||||
extern PlayerRace PlayerRaces; /// Player races
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// Get race array index by race type
|
||||
extern int PlayerRacesIndex(int race);
|
||||
|
||||
/// Init players
|
||||
extern void InitPlayers(void);
|
||||
/// Clean up players
|
||||
|
|
|
@ -565,7 +565,7 @@ global void DrawButtonPanel(void)
|
|||
*/
|
||||
local void UpdateButtonPanelMultipleUnits(void)
|
||||
{
|
||||
const char* unit_ident;
|
||||
char unit_ident[128];
|
||||
int z;
|
||||
int i;
|
||||
|
||||
|
@ -574,23 +574,11 @@ local void UpdateButtonPanelMultipleUnits(void)
|
|||
_current_buttons[z].Pos = -1;
|
||||
}
|
||||
|
||||
IfDebug( unit_ident=""; ); // keep the compiler happy
|
||||
|
||||
// when we have more races this should become a function
|
||||
switch( ThisPlayer->Race ) {
|
||||
case PlayerRaceHuman:
|
||||
unit_ident=",human-group,";
|
||||
break;
|
||||
case PlayerRaceOrc:
|
||||
unit_ident=",orc-group,";
|
||||
break;
|
||||
case PlayerRaceNeutral:
|
||||
unit_ident=",neutral-group,";
|
||||
break;
|
||||
default:
|
||||
DebugLevel0("what %d "_C_ ThisPlayer->Race);
|
||||
abort();
|
||||
i=PlayerRacesIndex(ThisPlayer->Race);
|
||||
if( i==-1 ) {
|
||||
i=PlayerRaces.Race[PlayerRaces.Count-1];
|
||||
}
|
||||
sprintf(unit_ident,",%s-group,",PlayerRaces.Name[i]);
|
||||
|
||||
for( z = 0; z < NumUnitButtons; z++ ) {
|
||||
if ( UnitButtonTable[z]->Level != CurrentButtonLevel ) {
|
||||
|
|
Loading…
Reference in a new issue