include/game.h File Reference

#include <time.h>

Include dependency graph for game.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gamestr

Defines

#define putgame()   ef_write(EF_GAME, 0, ef_ptr(EF_GAME, 0))
#define getgamep()   ((struct gamestr *)ef_ptr(EF_GAME, 0))

Functions

void game_ctrl_update (int)
int updates_disabled (void)
void game_record_update (time_t)
gamestrgame_tick_tick (void)
int game_tick_to_now (short *)
int game_step_a_tick (struct gamestr *, short *)
int game_reset_tick (short *)


Define Documentation

 
#define getgamep (  )     ((struct gamestr *)ef_ptr(EF_GAME, 0))

Definition at line 54 of file game.h.

Referenced by game_ctrl_update(), game_record_update(), game_tick_tick(), and updates_disabled().

 
#define putgame (  )     ef_write(EF_GAME, 0, ef_ptr(EF_GAME, 0))

Definition at line 53 of file game.h.

Referenced by game_ctrl_update(), game_record_update(), and game_tick_tick().


Function Documentation

void game_ctrl_update ( int   ) 

Definition at line 57 of file game.c.

References gamestr::game_upd_disable, getgamep, and putgame.

Referenced by disa(), and enab().

00058 {
00059     struct gamestr *game = getgamep();
00060 
00061     game->game_upd_disable = !enable;
00062     putgame();
00063 }

void game_record_update ( time_t   ) 

Definition at line 78 of file game.c.

References gamestr::game_rt, gamestr::game_tick, gamestr::game_turn, getgamep, and putgame.

Referenced by update_main().

00079 {
00080     struct gamestr *game = getgamep();
00081 
00082     game->game_turn++;
00083     game->game_tick = 0;
00084     game->game_rt = now;
00085     putgame();
00086 }

int game_reset_tick ( short *   ) 

Definition at line 165 of file game.c.

References CANT_HAPPEN, and etu_per_update.

Referenced by mob_land(), mob_plane(), mob_sect(), mob_ship(), and prod_nat().

00166 {
00167     int etu;
00168 
00169     etu = etu_per_update - *tick;
00170     if (CANT_HAPPEN(etu < 0))
00171         etu = 0;
00172     *tick = 0;
00173     return etu;
00174 }

int game_step_a_tick ( struct gamestr ,
short *   
)

Definition at line 149 of file game.c.

References CANT_HAPPEN, and gamestr::game_tick.

Referenced by game_tick_to_now().

00150 {
00151     int etu;
00152 
00153     etu = game->game_tick - *tick;
00154     if (CANT_HAPPEN(etu < 0))
00155         etu = 0;
00156     *tick = game->game_tick;
00157     return etu;
00158 }

struct gamestr* game_tick_tick ( void   )  [read]

Definition at line 111 of file game.c.

References CANT_HAPPEN, etu_per_update, gamestr::game_rt, gamestr::game_tick, getgamep, int, NULL, putgame, and secs_per_etu().

Referenced by game_tick_to_now(), and show_updates().

00112 {
00113     struct gamestr *game = getgamep();
00114     double dsecs, s_p_etu;
00115     int detu;
00116 
00117     dsecs = time(NULL) - game->game_rt;
00118     if (CANT_HAPPEN(dsecs < 0))
00119         dsecs = 0;
00120     s_p_etu = secs_per_etu(game);
00121     detu = (int)(dsecs / s_p_etu);
00122     if (detu > 0) {
00123         if (CANT_HAPPEN(game->game_tick + detu > etu_per_update))
00124             detu = etu_per_update - game->game_tick;
00125         game->game_tick += detu;
00126         game->game_rt += detu * s_p_etu;
00127         putgame();
00128     }
00129 
00130     return game;
00131 }

Here is the call graph for this function:

int game_tick_to_now ( short *   ) 

Definition at line 138 of file game.c.

References game_step_a_tick(), and game_tick_tick().

Referenced by bsanct(), build_bridge(), build_land(), build_plane(), build_ship(), build_tower(), check_trade(), explore(), init_nats(), lnd_do_upd_mob(), pln_do_upd_mob(), sct_do_upd_mob(), shp_do_upd_mob(), takeover(), takeover_land(), and takeover_ship().

00139 {
00140     return game_step_a_tick(game_tick_tick(), tick);
00141 }

Here is the call graph for this function:

int updates_disabled ( void   ) 

Definition at line 69 of file game.c.

References getgamep.

Referenced by demandupdatecheck(), force(), show_updates(), shut(), upda(), and update_sched().

00070 {
00071     return getgamep()->game_upd_disable;
00072 }


Generated on Fri Mar 28 11:01:22 2008 for empserver by  doxygen 1.5.2