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.27 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.30 by root, Sat Sep 16 22:24:13 2006 UTC

191 * goes someplace. 191 * goes someplace.
192 */ 192 */
193void 193void
194enter_player_savebed (object *op) 194enter_player_savebed (object *op)
195{ 195{
196 mapstruct *oldmap = op->map; 196 maptile *oldmap = op->map;
197 object *tmp; 197 object *tmp;
198 198
199 tmp = get_object (); 199 tmp = get_object ();
200 200
201 EXIT_PATH (tmp) = op->contr->savebed_map; 201 EXIT_PATH (tmp) = op->contr->savebed_map;
226 * the counts on the map if needed. 226 * the counts on the map if needed.
227 */ 227 */
228void 228void
229leave_map (object *op) 229leave_map (object *op)
230{ 230{
231 mapstruct *oldmap = op->map; 231 maptile *oldmap = op->map;
232 232
233 remove_ob (op); 233 remove_ob (op);
234 234
235 if (oldmap) 235 if (oldmap)
236 { 236 {
249 * player to - it could be the map he just came from if the load failed for 249 * player to - it could be the map he just came from if the load failed for
250 * whatever reason. If default map coordinates are to be used, then 250 * whatever reason. If default map coordinates are to be used, then
251 * the function that calls this should figure them out. 251 * the function that calls this should figure them out.
252 */ 252 */
253static void 253static void
254enter_map (object *op, mapstruct *newmap, int x, int y) 254enter_map (object *op, maptile *newmap, int x, int y)
255{ 255{
256 mapstruct *oldmap = op->map; 256 maptile *oldmap = op->map;
257 257
258 if (out_of_map (newmap, x, y)) 258 if (out_of_map (newmap, x, y))
259 { 259 {
260 LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->path, x, y); 260 LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->path, x, y);
261 x = MAP_ENTER_X (newmap); 261 x = MAP_ENTER_X (newmap);
381 } 381 }
382 } 382 }
383} 383}
384 384
385void 385void
386set_map_timeout (mapstruct *oldmap) 386set_map_timeout (maptile *oldmap)
387{ 387{
388#if MAP_MAXTIMEOUT 388#if MAP_MAXTIMEOUT
389 oldmap->timeout = MAP_TIMEOUT (oldmap); 389 oldmap->timeout = MAP_TIMEOUT (oldmap);
390 /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is 390 /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is
391 * lower than the min value. 391 * lower than the min value.
452 */ 452 */
453 453
454static void 454static void
455enter_random_map (object *pl, object *exit_ob) 455enter_random_map (object *pl, object *exit_ob)
456{ 456{
457 mapstruct *new_map; 457 maptile *new_map;
458 char newmap_name[HUGE_BUF], *cp; 458 char newmap_name[HUGE_BUF], *cp;
459 static int reference_number = 0; 459 static int reference_number = 0;
460 RMParms rp; 460 RMParms rp;
461 461
462 memset (&rp, 0, sizeof (RMParms)); 462 memset (&rp, 0, sizeof (RMParms));
522 */ 522 */
523 523
524static void 524static void
525enter_fixed_template_map (object *pl, object *exit_ob) 525enter_fixed_template_map (object *pl, object *exit_ob)
526{ 526{
527 mapstruct *new_map; 527 maptile *new_map;
528 char tmpnum[32], exitpath[HUGE_BUF], resultname[HUGE_BUF], tmpstring[HUGE_BUF], *sourcemap; 528 char tmpnum[32], exitpath[HUGE_BUF], resultname[HUGE_BUF], tmpstring[HUGE_BUF], *sourcemap;
529 const char *new_map_name; 529 const char *new_map_name;
530 530
531 /* Split the exit path string into two parts, one 531 /* Split the exit path string into two parts, one
532 * for where to store the map, and one for were 532 * for where to store the map, and one for were
614 */ 614 */
615 615
616static void 616static void
617enter_random_template_map (object *pl, object *exit_ob) 617enter_random_template_map (object *pl, object *exit_ob)
618{ 618{
619 mapstruct *new_map; 619 maptile *new_map;
620 char tmpnum[32], resultname[HUGE_BUF], tmpstring[HUGE_BUF]; 620 char tmpnum[32], resultname[HUGE_BUF], tmpstring[HUGE_BUF];
621 const char *new_map_name; 621 const char *new_map_name;
622 RMParms rp; 622 RMParms rp;
623 623
624 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord 624 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord
686 */ 686 */
687static void 687static void
688enter_unique_map (object *op, object *exit_ob) 688enter_unique_map (object *op, object *exit_ob)
689{ 689{
690 char apartment[HUGE_BUF]; 690 char apartment[HUGE_BUF];
691 mapstruct *newmap; 691 maptile *newmap;
692 692
693 if (EXIT_PATH (exit_ob)[0] == '/') 693 if (EXIT_PATH (exit_ob)[0] == '/')
694 { 694 {
695 sprintf (apartment, "%s/%s/%s/%s", settings.localdir, settings.playerdir, &op->name, clean_path (EXIT_PATH (exit_ob))); 695 sprintf (apartment, "%s/%s/%s/%s", settings.localdir, settings.playerdir, &op->name, clean_path (EXIT_PATH (exit_ob)));
696 newmap = ready_map_name (apartment, MAP_PLAYER_UNIQUE); 696 newmap = ready_map_name (apartment, MAP_PLAYER_UNIQUE);
819 int x = EXIT_X (exit_ob), y = EXIT_Y (exit_ob); 819 int x = EXIT_X (exit_ob), y = EXIT_Y (exit_ob);
820 820
821 /* 'Normal' exits that do not do anything special 821 /* 'Normal' exits that do not do anything special
822 * Simple enough we don't need another routine for it. 822 * Simple enough we don't need another routine for it.
823 */ 823 */
824 mapstruct *newmap; 824 maptile *newmap;
825 825
826 if (exit_ob->map) 826 if (exit_ob->map)
827 { 827 {
828 newmap = ready_map_name (path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob)), 0); 828 newmap = ready_map_name (path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob)), 0);
829 /* Random map was previously generated, but is no longer about. Lets generate a new 829 /* Random map was previously generated, but is no longer about. Lets generate a new
918 hit_player (op, exit_ob->stats.dam, exit_ob, exit_ob->attacktype, 1); 918 hit_player (op, exit_ob->stats.dam, exit_ob, exit_ob->attacktype, 1);
919 } 919 }
920 else 920 else
921 { 921 {
922 int flags = 0; 922 int flags = 0;
923 mapstruct *newmap; 923 maptile *newmap;
924 924
925 925
926 /* Hypothetically, I guess its possible that a standard map matches 926 /* Hypothetically, I guess its possible that a standard map matches
927 * the localdir, but that seems pretty unlikely - unlikely enough that 927 * the localdir, but that seems pretty unlikely - unlikely enough that
928 * I'm not going to attempt to try to deal with that possibility. 928 * I'm not going to attempt to try to deal with that possibility.
964 964
965#if 0 // dead code, schmorp 965#if 0 // dead code, schmorp
966void 966void
967process_active_maps () 967process_active_maps ()
968{ 968{
969 for (mapstruct *map = first_map; map != NULL; map = map->next) 969 for (maptile *map = first_map; map != NULL; map = map->next)
970 if (map->in_memory == MAP_IN_MEMORY) 970 if (map->in_memory == MAP_IN_MEMORY)
971 if (players_on_map (map, TRUE)) 971 if (players_on_map (map, TRUE))
972 process_events (map); 972 process_events (map);
973} 973}
974#endif 974#endif
980 * objects have been updated, process_players2() does the processing that 980 * objects have been updated, process_players2() does the processing that
981 * is needed after the players have been updated. 981 * is needed after the players have been updated.
982 */ 982 */
983 983
984void 984void
985process_players1 (mapstruct *map) 985process_players1 (maptile *map)
986{ 986{
987 int flag; 987 int flag;
988 player *pl, *plnext; 988 player *pl, *plnext;
989 989
990 /* Basically, we keep looping until all the players have done their actions. */ 990 /* Basically, we keep looping until all the players have done their actions. */
1057 /* draw(pl->ob); *//* updated in socket code */ 1057 /* draw(pl->ob); *//* updated in socket code */
1058 } 1058 }
1059} 1059}
1060 1060
1061void 1061void
1062process_players2 (mapstruct *map) 1062process_players2 (maptile *map)
1063{ 1063{
1064 player *pl; 1064 player *pl;
1065 1065
1066 /* Then check if any players should use weapon-speed instead of speed */ 1066 /* Then check if any players should use weapon-speed instead of speed */
1067 for (pl = first_player; pl != NULL; pl = pl->next) 1067 for (pl = first_player; pl != NULL; pl = pl->next)
1097 pl->ob->speed_left = pl->ob->speed; 1097 pl->ob->speed_left = pl->ob->speed;
1098 } 1098 }
1099} 1099}
1100 1100
1101void 1101void
1102process_events (mapstruct *map) 1102process_events (maptile *map)
1103{ 1103{
1104 object *op; 1104 object *op;
1105 tag_t tag;
1106 1105
1107 static object *marker; 1106 static object *marker;
1108
1109 if (!marker) 1107 if (!marker)
1110 marker = get_object (); 1108 marker = get_object ();
1111 1109
1112 process_players1 (map); 1110 process_players1 (map);
1113 1111
1120 active_objects = marker; 1118 active_objects = marker;
1121 1119
1122 while (marker->active_next) 1120 while (marker->active_next)
1123 { 1121 {
1124 op = marker->active_next; 1122 op = marker->active_next;
1125 tag = op->count;
1126 1123
1127 /* Move marker forward - swap op and marker */ 1124 /* Move marker forward - swap op and marker */
1128 op->active_prev = marker->active_prev; 1125 op->active_prev = marker->active_prev;
1129 1126
1130 if (op->active_prev) 1127 if (op->active_prev)
1217 LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null"); 1214 LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null");
1218 } 1215 }
1219#endif 1216#endif
1220 --op->speed_left; 1217 --op->speed_left;
1221 process_object (op); 1218 process_object (op);
1219
1222 if (was_destroyed (op, tag)) 1220 if (op->destroyed ())
1223 continue; 1221 continue;
1224 } 1222 }
1223
1225 if (settings.casting_time == TRUE && op->casting_time > 0) 1224 if (settings.casting_time == TRUE && op->casting_time > 0)
1226 op->casting_time--; 1225 op->casting_time--;
1226
1227 if (op->speed_left <= 0) 1227 if (op->speed_left <= 0)
1228 op->speed_left += FABS (op->speed); 1228 op->speed_left += FABS (op->speed);
1229 } 1229 }
1230 1230
1231 /* Remove marker object from active list */ 1231 /* Remove marker object from active list */
1238} 1238}
1239 1239
1240void 1240void
1241clean_tmp_files (void) 1241clean_tmp_files (void)
1242{ 1242{
1243 mapstruct *m, *next; 1243 maptile *m, *next;
1244 1244
1245 LOG (llevInfo, "Cleaning up...\n"); 1245 LOG (llevInfo, "Cleaning up...\n");
1246 1246
1247 /* We save the maps - it may not be intuitive why, but if there are unique 1247 /* We save the maps - it may not be intuitive why, but if there are unique
1248 * items, we need to save the map so they get saved off. Perhaps we should 1248 * items, we need to save the map so they get saved off. Perhaps we should
1276/* clean up everything before exiting */ 1276/* clean up everything before exiting */
1277void 1277void
1278cleanup (void) 1278cleanup (void)
1279{ 1279{
1280 LOG (llevDebug, "Cleanup called.\n"); 1280 LOG (llevDebug, "Cleanup called.\n");
1281
1282 for (player *pl = first_player; pl != NULL; pl = pl->next)
1283 save_player (pl->ob, 0);
1284
1285 for (player *pl = first_player; pl != NULL; pl = pl->next)
1286 if (!QUERY_FLAG (pl->ob, FLAG_REMOVED))
1287 leave_map (pl->ob);
1288
1289 clean_tmp_files ();
1281 write_book_archive (); 1290 write_book_archive ();
1282 1291
1283 INVOKE_GLOBAL (CLEANUP); 1292 INVOKE_GLOBAL (CLEANUP);
1284 1293
1285 _exit (0); 1294 _exit (0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines