Fixed bug #542313: Sleep does not work with NEW_AI.
This commit is contained in:
parent
03e387b33e
commit
41c4b3a9fb
7 changed files with 23 additions and 12 deletions
|
@ -791,6 +791,7 @@
|
|||
<LI>Added keyboard, mouse, and game speed options. (from Nehal Mistry)
|
||||
<LI>Added master, music, and cd volume control options. (from Nehal Mistry)
|
||||
<LI>Added fog of war control to preferences. (from Nehal Mistry)
|
||||
<LI>Fixed bug #542313: Sleep does not work with NEW_AI.
|
||||
<LI>+++
|
||||
</UL>
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
global int AiSleep; /// Ai sleeps # frames
|
||||
global int AiSleepCycles; /// Ai sleeps # cycles
|
||||
global int AiTimeFactor = 100; /// Adjust the AI build times
|
||||
global int AiCostFactor = 100; /// Adjust the AI costs
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ typedef struct _player_ai_ {
|
|||
// controller
|
||||
SCM Script; /// Script executed
|
||||
int ScriptDebug; /// Flag script debuging on/off
|
||||
int SleepFrames; /// Frames to sleep
|
||||
int SleepCycles; /// Cycles to sleep
|
||||
|
||||
// forces
|
||||
#define AI_MAX_FORCES 10 /// How many forces are supported
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
-- Ai tables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
global int AiSleep = 0; /// Ai sleeps # frames
|
||||
global int AiSleepCycles; /// Ai sleeps # cycles
|
||||
global int AiTimeFactor = 100; /// Adjust the AI build times
|
||||
global int AiCostFactor = 100; /// Adjust the AI costs
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "freecraft.h"
|
||||
#include "unittype.h"
|
||||
#include "ccl.h"
|
||||
#include "ai.h"
|
||||
#include "ai_local.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -499,6 +500,14 @@ local SCM CclAiGetRace(void)
|
|||
return gh_symbol2scm(AiPlayer->Player->RaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
** Get the number of cycles to sleep.
|
||||
*/
|
||||
local SCM CclAiGetSleepCycles(void)
|
||||
{
|
||||
return gh_int2scm(AiSleepCycles);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -768,23 +777,23 @@ local SCM CclAiAttackWithForce(SCM value)
|
|||
}
|
||||
|
||||
/**
|
||||
** Sleep n frames.
|
||||
** Sleep n cycles.
|
||||
**
|
||||
** @param value Number of frames to delay.
|
||||
** @param value Number of cycles to delay.
|
||||
*/
|
||||
local SCM CclAiSleep(SCM value)
|
||||
{
|
||||
int i;
|
||||
|
||||
DebugLevel3Fn("%lu %d\n",GameCycle,AiPlayer->SleepFrames);
|
||||
if( AiPlayer->SleepFrames ) {
|
||||
if( AiPlayer->SleepFrames<GameCycle ) {
|
||||
AiPlayer->SleepFrames=0;
|
||||
DebugLevel3Fn("%lu %d\n",GameCycle,AiPlayer->SleepCycles);
|
||||
if( AiPlayer->SleepCycles ) {
|
||||
if( AiPlayer->SleepCycles<GameCycle ) {
|
||||
AiPlayer->SleepCycles=0;
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
} else {
|
||||
i=gh_scm2int(value);
|
||||
AiPlayer->SleepFrames=GameCycle+i;
|
||||
AiPlayer->SleepCycles=GameCycle+i;
|
||||
}
|
||||
|
||||
return SCM_BOOL_T;
|
||||
|
@ -1034,6 +1043,7 @@ global void AiCclRegister(void)
|
|||
|
||||
#if defined(NEW_AI)
|
||||
gh_new_procedure0_0("ai:get-race",CclAiGetRace);
|
||||
gh_new_procedure0_0("ai:get-sleep-cycles",CclAiGetSleepCycles);
|
||||
|
||||
gh_new_procedure1_0("ai:debug",CclAiDebug);
|
||||
gh_new_procedure1_0("ai:need",CclAiNeed);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
extern int AiSleep; /// Ai sleeps # frames
|
||||
extern int AiSleepCycles; /// Ai sleeps # cycles
|
||||
extern int AiTimeFactor; /// Adjust the AI build times
|
||||
extern int AiCostFactor; /// Adjust the AI costs
|
||||
|
||||
|
|
|
@ -836,7 +836,7 @@ global int main(int argc,char** argv)
|
|||
strncpy(NetworkName, optarg, 16);
|
||||
continue;
|
||||
case 's':
|
||||
AiSleep=atoi(optarg);
|
||||
AiSleepCycles=atoi(optarg);
|
||||
continue;
|
||||
case 't':
|
||||
AiTimeFactor=atoi(optarg);
|
||||
|
|
Loading…
Add table
Reference in a new issue