ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/main.C
(Generate patch)

Comparing deliantra/server/server/main.C (file contents):
Revision 1.4 by root, Thu Aug 24 13:13:49 2006 UTC vs.
Revision 1.7 by root, Sat Aug 26 08:44:06 2006 UTC

1/* 1/*
2 * static char *rcsid_main_c = 2 * static char *rcsid_main_c =
3 * "$Id: main.C,v 1.4 2006/08/24 13:13:49 root Exp $"; 3 * "$Id: main.C,v 1.7 2006/08/26 08:44:06 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
286 /* If it is a player login, he has yet to be inserted anyplace. 286 /* If it is a player login, he has yet to be inserted anyplace.
287 * otherwise, we need to deal with removing the playe here. 287 * otherwise, we need to deal with removing the playe here.
288 */ 288 */
289 if(!QUERY_FLAG(op, FLAG_REMOVED)) 289 if(!QUERY_FLAG(op, FLAG_REMOVED))
290 remove_ob(op); 290 remove_ob(op);
291
291 if (op->map!=NULL) 292 if (op->map!=NULL)
292 { 293 INVOKE_PLAYER (LEAVE, op->contr);
293 /* Lauwenmark : Here we handle the MAPLEAVE global event */ 294
294 execute_global_event(EVENT_MAPLEAVE, op);
295 }
296 /* remove_ob clears these so they must be reset after the remove_ob call */ 295 /* remove_ob clears these so they must be reset after the remove_ob call */
297 op->x = x; 296 op->x = x;
298 op->y = y; 297 op->y = y;
299 op->map = newmap; 298 op->map = newmap;
300 insert_ob_in_map(op,op->map,NULL,INS_NO_WALK_ON); 299 insert_ob_in_map(op,op->map,NULL,INS_NO_WALK_ON);
301 300
302 /* Lauwenmark : Here we handle the MAPENTER global event */ 301 INVOKE_PLAYER (ENTER, op->contr);
303 execute_global_event(EVENT_MAPENTER, op);
304 302
305 if (!op->contr->hidden) 303 if (!op->contr->hidden)
306 newmap->players++; 304 newmap->players++;
307 305
308 newmap->timeout=0; 306 newmap->timeout=0;
1187 * cleanup. We also leave that loop to actually handle the freeing 1185 * cleanup. We also leave that loop to actually handle the freeing
1188 * of the data. 1186 * of the data.
1189 */ 1187 */
1190 if (pl->ob->type != DEAD_OBJECT) 1188 if (pl->ob->type != DEAD_OBJECT)
1191 { 1189 {
1192 execute_global_event (EVENT_LOGOUT, pl, pl->socket.host);
1193 LOG (llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, pl->socket.host);
1194
1195 pl->socket.status = Ns_Dead; 1190 pl->socket.status = Ns_Dead;
1196 1191
1197 /* If a hidden dm dropped connection do not create 1192 /* If a hidden dm dropped connection do not create
1198 * inconsistencies by showing that they have left the game 1193 * inconsistencies by showing that they have left the game
1199 */ 1194 */
1200 if (!(QUERY_FLAG(pl->ob,FLAG_WIZ) && pl->ob->contr->hidden) 1195 if (!(QUERY_FLAG(pl->ob,FLAG_WIZ) && pl->ob->contr->hidden)
1201 && draw_exit 1196 && draw_exit
1202 && (pl->state != ST_GET_NAME && pl->state!=ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) 1197 && (pl->state != ST_GET_NAME && pl->state!=ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD))
1203 { 1198 {
1199 if (pl->ob->map)
1200 {
1201 INVOKE_PLAYER (LOGOUT, pl);
1202 LOG (llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, pl->socket.host);
1203 }
1204
1204 char buf[MAX_BUF]; 1205 char buf[MAX_BUF];
1205 sprintf (buf, "%s left the game.", pl->ob->name); 1206 sprintf (buf, "%s left the game.", pl->ob->name);
1206 new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf); 1207 new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf);
1207 } 1208 }
1208 1209
1316 /* Lauwenmark : Here we handle the CLOCK global event */ 1317 /* Lauwenmark : Here we handle the CLOCK global event */
1317 execute_global_event(EVENT_CLOCK); 1318 execute_global_event(EVENT_CLOCK);
1318 flush_sockets(); 1319 flush_sockets();
1319 check_active_maps(); /* Removes unused maps after a certain timeout */ 1320 check_active_maps(); /* Removes unused maps after a certain timeout */
1320 do_specials(); /* Routines called from time to time. */ 1321 do_specials(); /* Routines called from time to time. */
1322
1323 ++pticks;
1321} 1324}
1322 1325
1323int main(int argc, char **argv) 1326int main(int argc, char **argv)
1324{ 1327{
1325#ifdef WIN32 /* ---win32 this sets the win32 from 0d0a to 0a handling */
1326 _fmode = _O_BINARY ;
1327 bRunning = 1;
1328#endif
1329
1330#ifdef DEBUG_MALLOC_LEVEL
1331 malloc_debug(DEBUG_MALLOC_LEVEL);
1332#endif
1333
1334 settings.argc=argc; 1328 settings.argc = argc;
1335 settings.argv=argv; 1329 settings.argv = argv;
1330
1336 init(argc, argv); 1331 init (argc, argv);
1332
1337 initPlugins(); /* GROS - Init the Plugins */ 1333 initPlugins (); /* GROS - Init the Plugins */
1334 cfperl_init ();
1338 1335
1336 for (;;)
1339 cfperl_main (); 1337 cfperl_main ();
1340 1338
1339 // unreached
1341 emergency_save( 0 ); 1340 emergency_save (0);
1342 cleanup( ); 1341 cleanup ();
1342
1343 return 0; 1343 return 0;
1344} 1344}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines