Renamed FrameCounter to GameCycle. Network delay debug added.
This commit is contained in:
parent
a47f213588
commit
231d94aa17
12 changed files with 73 additions and 18 deletions
src
ai
game
include
network
stratagus
ui
|
@ -809,11 +809,11 @@ global void AiResearchComplete(Unit* unit,const Upgrade* what)
|
|||
}
|
||||
|
||||
/**
|
||||
** This is called for each player, each frame.
|
||||
** This is called for each player, each game cycle.
|
||||
**
|
||||
** @param player The player structure pointer.
|
||||
*/
|
||||
global void AiEachFrame(Player* player __attribute__((unused)))
|
||||
global void AiEachCycle(Player* player __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ local AiCommand AiTable1[] = {
|
|||
|
||||
/**
|
||||
** Define the AI goals.
|
||||
** All conditions the AI must check each frame.
|
||||
** All conditions the AI must check each game cycle.
|
||||
*/
|
||||
typedef struct _ai_goal_ AiGoal;
|
||||
|
||||
|
@ -1564,11 +1564,11 @@ global void AiResearchComplete(Unit* unit,const Upgrade* what)
|
|||
}
|
||||
|
||||
/**
|
||||
** This is called for each player, each frame.
|
||||
** This is called for each player, each game cycle.
|
||||
**
|
||||
** @param player The player structure pointer.
|
||||
*/
|
||||
global void AiEachFrame(Player * player)
|
||||
global void AiEachCycle(Player * player)
|
||||
{
|
||||
AiCommand command;
|
||||
|
||||
|
|
|
@ -433,9 +433,9 @@ local SCM CclAddTrigger(SCM condition,SCM action)
|
|||
}
|
||||
|
||||
/**
|
||||
** Check trigger each frame.
|
||||
** Check trigger each game cycle.
|
||||
*/
|
||||
global void TriggersEachFrame(void)
|
||||
global void TriggersEachCycle(void)
|
||||
{
|
||||
SCM pair;
|
||||
SCM val;
|
||||
|
|
|
@ -174,7 +174,7 @@ extern void HandleActionSpellCast(Unit* unit);
|
|||
|
||||
/// handle the animation of a unit
|
||||
extern int UnitShowAnimation(Unit* unit,const Animation* animation);
|
||||
/// Handle the actions of all units each frame
|
||||
/// Handle the actions of all units each game cycle
|
||||
extern void UnitActions(void);
|
||||
|
||||
//@}
|
||||
|
|
|
@ -46,7 +46,7 @@ extern int AiCostFactor; /// Adjust the AI costs
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
extern void AiEachFrame(Player* player);/// Called each frame
|
||||
extern void AiEachCycle(Player* player);/// Called each game cycle
|
||||
extern void AiEachSecond(Player* player);/// Called each second
|
||||
|
||||
extern void AiInit(Player* player); /// Init AI for this player
|
||||
|
|
|
@ -140,6 +140,7 @@ extern int NetworkFildes; /// Network file descriptor
|
|||
extern int NetworkInSync; /// Network is in sync
|
||||
extern int NetworkUpdates; /// Network update each # game cycles
|
||||
extern int NetworkLag; /// Network lag (# game cycles)
|
||||
extern int NetworkStatus[PlayerMax]; /// Network status
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
|
|
@ -488,8 +488,8 @@ extern int HaveUnitTypeByIdent(const Player* player,const char* ident);
|
|||
|
||||
/// Initialize the computer opponent AI
|
||||
extern void PlayersInitAi(void);
|
||||
/// Called each frame for player handlers (AI)
|
||||
extern void PlayersEachFrame(void);
|
||||
/// Called each game cycle for player handlers (AI)
|
||||
extern void PlayersEachCycle(void);
|
||||
/// Called each second for player handlers (AI)
|
||||
extern void PlayersEachSecond(void);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
extern void TriggersEachFrame(void); /// test triggers
|
||||
extern void TriggersEachCycle(void); /// test triggers
|
||||
|
||||
extern void TriggerCclRegister(void); /// Register ccl features
|
||||
extern void SaveTriggers(FILE*); /// Save the trigger module
|
||||
|
|
|
@ -267,6 +267,7 @@ global int NetworkFildes = -1; /// Network file descriptor
|
|||
global int NetworkInSync = 1; /// Network is in sync
|
||||
global int NetworkUpdates = 5; /// Network update each # game cycles
|
||||
global int NetworkLag = 5; /// Network lag in # game cycles
|
||||
global int NetworkStatus[PlayerMax]; /// Network status
|
||||
|
||||
local char NetMsgBuf[128][PlayerMax]; /// Chat message buffers
|
||||
local int NetMsgBufLen[PlayerMax]; /// Stored chat message length
|
||||
|
@ -286,6 +287,7 @@ local int NetworkReceivedPackets; /// Packets received packets
|
|||
local int NetworkReceivedEarly; /// Packets received too early
|
||||
local int NetworkReceivedLate; /// Packets received too late
|
||||
local int NetworkReceivedDups; /// Packets received as duplicates
|
||||
local int NetworkReceivedLost; /// Packets received packet lost
|
||||
|
||||
local int NetworkSendPackets; /// Packets send packets
|
||||
local int NetworkSendResend; /// Packets send to resend
|
||||
|
@ -459,9 +461,9 @@ global void ExitNetwork1(void)
|
|||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
DebugLevel0("Received: %d packets, %d early, %d late, %d dups\n",
|
||||
DebugLevel0("Received: %d packets, %d early, %d late, %d dups, %d lost.\n",
|
||||
NetworkReceivedPackets, NetworkReceivedEarly, NetworkReceivedLate,
|
||||
NetworkReceivedDups);
|
||||
NetworkReceivedDups,NetworkReceivedLost);
|
||||
DebugLevel0("Send: %d packets, %d resend\n",
|
||||
NetworkSendPackets, NetworkSendResend);
|
||||
#endif
|
||||
|
@ -548,7 +550,7 @@ global void NetworkSendCommand(int command, const Unit *unit, int x, int y,
|
|||
|
||||
/**
|
||||
** Called if message for the network is ready.
|
||||
** (by WaitEventsAndKeepSync)
|
||||
** (by WaitEventsOneFrame)
|
||||
**
|
||||
** @todo
|
||||
** NetworkReceivedEarly NetworkReceivedLate NetworkReceivedDups
|
||||
|
@ -677,6 +679,25 @@ global void NetworkEvent(void)
|
|||
nc->Type, n, nc->Cycle);
|
||||
}
|
||||
|
||||
// Receive statistic
|
||||
if( n>NetworkStatus[player] ) {
|
||||
NetworkStatus[player] = n;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if( i ) {
|
||||
// Not in first slot and not got packet lost!
|
||||
// FIXME: if more than 1 in sequence is lost, I count one to much!
|
||||
if( NetworkIn[nc->Cycle][player].Time != n ) {
|
||||
++NetworkReceivedLost;
|
||||
}
|
||||
} else {
|
||||
// FIXME: more network statistic
|
||||
if( NetworkIn[nc->Cycle][player].Time == n ) {
|
||||
++NetworkReceivedDups;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Place in network in
|
||||
NetworkIn[nc->Cycle][player].Time = n;
|
||||
NetworkIn[nc->Cycle][player].Data = *nc;
|
||||
|
|
|
@ -313,8 +313,36 @@ global void UpdateDisplay(void)
|
|||
if( f<0 || f>168 ) {
|
||||
f=168;
|
||||
}
|
||||
VideoDrawHLine(ColorGreen,TheUI.MenuButtonX,TheUI.MenuButtonY,f);
|
||||
VideoDrawHLine(ColorRed,TheUI.MenuButtonX+f,TheUI.MenuButtonY,168-f);
|
||||
if( f ) {
|
||||
VideoDrawHLine(ColorGreen,TheUI.MenuButtonX,TheUI.MenuButtonY,f);
|
||||
}
|
||||
if( 168-f ) {
|
||||
VideoDrawHLine(ColorRed,TheUI.MenuButtonX+f,TheUI.MenuButtonY,168-f);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Draw line for network speed.
|
||||
//
|
||||
{
|
||||
int i;
|
||||
int f;
|
||||
|
||||
if( NetworkLag ) {
|
||||
for( i=0; i<PlayerMax; ++i ) {
|
||||
f=16-(16*(NetworkStatus[i]-GameCycle))/(NetworkLag*2);
|
||||
if( f<0 || f>16 ) {
|
||||
f=16;
|
||||
}
|
||||
if( f ) {
|
||||
VideoDrawHLine(ColorRed,
|
||||
TheUI.MenuButtonX,TheUI.MenuButtonY+1+i,f);
|
||||
}
|
||||
if( 16-f ) {
|
||||
VideoDrawHLine(ColorGreen,
|
||||
TheUI.MenuButtonX+f,TheUI.MenuButtonY+1+i,16-f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -830,6 +830,11 @@ global int main(int argc,char** argv)
|
|||
|
||||
case 'L':
|
||||
NetworkLag=atoi(optarg);
|
||||
if( !NetworkLag ) {
|
||||
fprintf(stderr,"FIXME: zero lag not supported\n");
|
||||
Usage();
|
||||
exit(-1);
|
||||
}
|
||||
continue;
|
||||
case 'U':
|
||||
NetworkUpdates=atoi(optarg);
|
||||
|
|
|
@ -1022,7 +1022,7 @@ global void InputMouseExit(const EventCallback* callbacks,
|
|||
}
|
||||
|
||||
/**
|
||||
** Called each frame to handle mouse time outs.
|
||||
** Called each frame to handle mouse timeouts.
|
||||
**
|
||||
** @param callbacks Callback structure for events.
|
||||
** @param ticks Denotes time-stamp of video-system
|
||||
|
|
Loading…
Add table
Reference in a new issue