diff --git a/src/include/freecraft.h b/src/include/freecraft.h index 76e13d3cc..7d4001ae8 100644 --- a/src/include/freecraft.h +++ b/src/include/freecraft.h @@ -279,6 +279,9 @@ extern char* strdcat(const char* l, const char* r); /// strdup + strcat + strcat extern char* strdcat3(const char* l, const char *m, const char* r); + /// Build libary path name +extern char* LibraryFileName(const char* file,char* buffer); + /*============================================================================ == Misc ============================================================================*/ diff --git a/src/include/upgrade.h b/src/include/upgrade.h index 07ea8b10c..55826c575 100644 --- a/src/include/upgrade.h +++ b/src/include/upgrade.h @@ -171,23 +171,26 @@ void UpgradeLost2( Player* player, char* sid ); // by ident string ----------------------------------------------------------------------------*/ // all the following functions are just map handlers, no specific notes -void AllowUnitId( Player* player, int id, char af ); // id -- unit type id, af -- `A'llow/`F'orbid +// id -- unit type id, af -- `A'llow/`F'orbid +extern void AllowUnitId( Player* player, int id, char af ); extern void AllowUnitByIdent( Player* player, const char* sid, char af ); -void AllowActionId( Player* player, int id, char af ); -void AllowActionByIdent( Player* player, const char* sid, char af ); +extern void AllowActionId( Player* player, int id, char af ); +extern void AllowActionByIdent( Player* player, const char* sid, char af ); -void AllowUpgradeId( Player* player, int id, char af ); -void AllowUpgradeByIdent( Player* player, const char* sid, char af ); +extern void AllowUpgradeId( Player* player, int id, char af ); +extern void AllowUpgradeByIdent( Player* player, const char* sid, char af ); -char UnitIdAllowed(const Player* player, int id ); -char UnitIdentAllowed(const Player* player,const char* sid ); +extern void AllowByIdent( Player* player, const char* sid, char af ); -char ActionIdAllowed(const Player* player, int id ); -char ActionIdentAllowed(const Player* player,const char* sid ); +extern char UnitIdAllowed(const Player* player, int id ); +extern char UnitIdentAllowed(const Player* player,const char* sid ); -char UpgradeIdAllowed(const Player* player, int id ); -char UpgradeIdentAllowed(const Player* player,const char* sid ); +extern char ActionIdAllowed(const Player* player, int id ); +extern char ActionIdentAllowed(const Player* player,const char* sid ); + +extern char UpgradeIdAllowed(const Player* player, int id ); +extern char UpgradeIdentAllowed(const Player* player,const char* sid ); /*---------------------------------------------------------------------------- -- eof diff --git a/src/unit/upgrade.cpp b/src/unit/upgrade.cpp index 025a247f9..13273855b 100644 --- a/src/unit/upgrade.cpp +++ b/src/unit/upgrade.cpp @@ -398,6 +398,7 @@ global void InitUpgrades(void) { int z; + DebugLevel3(__FUNCTION__": ---------------------------------------\n"); if( !UpgradesCount ) { InitIcons(); // wired, but I need them here @@ -941,11 +942,38 @@ local SCM CclDefineUpgrade(SCM list) } /** -** Define the allow. +** Define which units/upgrades are allowed. */ local SCM CclDefineAllow(SCM list) { - DebugLevel0(__FUNCTION__": not written\n"); + SCM value; + char* str; + char* ids; + int i; + int n; + + while( !gh_null_p(list) ) { + value=gh_car(list); + list=gh_cdr(list); + str=gh_scm2newstr(value,NULL); + value=gh_car(list); + list=gh_cdr(list); + ids=gh_scm2newstr(value,NULL); + + DebugLevel3(__FUNCTION__"\tName: %s - %s\n",str,ids); + + n=strlen(ids); + if( n>16 ) { + n=16; + } + + for( i=0; i<n; ++i ) { + AllowByIdent(&Players[i],str,ids[i]); + } + + free(str); + free(ids); + } return SCM_UNSPECIFIED; } @@ -1383,6 +1411,17 @@ void AllowActionByIdent( Player* player, const char* sid, char af ) void AllowUpgradeByIdent( Player* player, const char* sid, char af ) { AllowUpgradeId( player, UpgradeIdByIdent(sid), af ); }; +void AllowByIdent(Player* player, const char* sid, char af ) +{ + if( !strncmp(sid,"unit-",5) ) { + AllowUnitByIdent(player,sid,af); + } else if( !strncmp(sid,"upgrade-",8) ) { + AllowUpgradeByIdent(player,sid,af); + } else { + DebugLevel0(__FUNCTION__": wrong sid %s\n",sid); + } +} + char UnitIdentAllowed(const Player* player,const char* sid ) { return UnitIdAllowed( player, UnitTypeIdByIdent(sid) ); }; char ActionIdentAllowed(const Player* player,const char* sid )