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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines