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.8 by root, Sun Aug 27 16:15:13 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.8 2006/08/27 16:15:13 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 {
293 /* Lauwenmark : Here we handle the MAPLEAVE global event */ 294 INVOKE_PLAYER (LEAVE, op->contr, ARG_MAP (op->map));
294 execute_global_event(EVENT_MAPLEAVE, op); 295 INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr));
295 } 296 }
297
296 /* remove_ob clears these so they must be reset after the remove_ob call */ 298 /* remove_ob clears these so they must be reset after the remove_ob call */
297 op->x = x; 299 op->x = x;
298 op->y = y; 300 op->y = y;
299 op->map = newmap; 301 op->map = newmap;
300 insert_ob_in_map(op,op->map,NULL,INS_NO_WALK_ON); 302 insert_ob_in_map(op,op->map,NULL,INS_NO_WALK_ON);
301 303
302 /* Lauwenmark : Here we handle the MAPENTER global event */ 304 INVOKE_PLAYER (ENTER, op->contr, ARG_MAP (op->map));
303 execute_global_event(EVENT_MAPENTER, op); 305 INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr));
304 306
305 if (!op->contr->hidden) 307 if (!op->contr->hidden)
306 newmap->players++; 308 newmap->players++;
307 309
308 newmap->timeout=0; 310 newmap->timeout=0;
1187 * cleanup. We also leave that loop to actually handle the freeing 1189 * cleanup. We also leave that loop to actually handle the freeing
1188 * of the data. 1190 * of the data.
1189 */ 1191 */
1190 if (pl->ob->type != DEAD_OBJECT) 1192 if (pl->ob->type != DEAD_OBJECT)
1191 { 1193 {
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; 1194 pl->socket.status = Ns_Dead;
1196 1195
1197 /* If a hidden dm dropped connection do not create 1196 /* If a hidden dm dropped connection do not create
1198 * inconsistencies by showing that they have left the game 1197 * inconsistencies by showing that they have left the game
1199 */ 1198 */
1200 if (!(QUERY_FLAG(pl->ob,FLAG_WIZ) && pl->ob->contr->hidden) 1199 if (!(QUERY_FLAG(pl->ob,FLAG_WIZ) && pl->ob->contr->hidden)
1201 && draw_exit 1200 && draw_exit
1202 && (pl->state != ST_GET_NAME && pl->state!=ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) 1201 && (pl->state != ST_GET_NAME && pl->state!=ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD))
1203 { 1202 {
1203 if (pl->ob->map)
1204 {
1205 INVOKE_PLAYER (LOGOUT, pl);
1206 LOG (llevInfo,"LOGOUT: Player named %s from ip %s\n", pl->ob->name, pl->socket.host);
1207 }
1208
1204 char buf[MAX_BUF]; 1209 char buf[MAX_BUF];
1205 sprintf (buf, "%s left the game.", pl->ob->name); 1210 sprintf (buf, "%s left the game.", pl->ob->name);
1206 new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf); 1211 new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, buf);
1207 } 1212 }
1208 1213
1316 /* Lauwenmark : Here we handle the CLOCK global event */ 1321 /* Lauwenmark : Here we handle the CLOCK global event */
1317 execute_global_event(EVENT_CLOCK); 1322 execute_global_event(EVENT_CLOCK);
1318 flush_sockets(); 1323 flush_sockets();
1319 check_active_maps(); /* Removes unused maps after a certain timeout */ 1324 check_active_maps(); /* Removes unused maps after a certain timeout */
1320 do_specials(); /* Routines called from time to time. */ 1325 do_specials(); /* Routines called from time to time. */
1326
1327 ++pticks;
1321} 1328}
1322 1329
1323int main(int argc, char **argv) 1330int main(int argc, char **argv)
1324{ 1331{
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; 1332 settings.argc = argc;
1335 settings.argv=argv; 1333 settings.argv = argv;
1334
1336 init(argc, argv); 1335 init (argc, argv);
1336
1337 initPlugins(); /* GROS - Init the Plugins */ 1337 initPlugins (); /* GROS - Init the Plugins */
1338 cfperl_init ();
1338 1339
1340 for (;;)
1339 cfperl_main (); 1341 cfperl_main ();
1340 1342
1343 // unreached
1341 emergency_save( 0 ); 1344 emergency_save (0);
1342 cleanup( ); 1345 cleanup ();
1346
1343 return 0; 1347 return 0;
1344} 1348}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines