Skip to content

Commit 2fe789f

Browse files
authored
Merge pull request #3595 from Goober5000/ship_logging
improve logging of ship creation and cleanup
2 parents f850725 + 10b3571 commit 2fe789f

File tree

5 files changed

+66
-42
lines changed

5 files changed

+66
-42
lines changed

code/mission/missionlog.cpp

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,67 @@ void mission_log_add_entry(LogType type, const char *pname, const char *sname, i
383383
nprintf(("missionlog", "new highwater point reached for mission log (%d entries).\n", last_entry));
384384
}
385385
}
386-
#endif
387386

387+
float mission_time = f2fl(Missiontime);
388+
int minutes = (int)(mission_time / 60);
389+
int seconds = (int)mission_time % 60;
390+
391+
// record the entry to the debug log too
392+
switch (entry->type) {
393+
case LOG_SHIP_DESTROYED:
394+
case LOG_WING_DESTROYED:
395+
nprintf(("missionlog", "MISSION LOG: %s destroyed at %02d:%02d\n", entry->pname, minutes, seconds));
396+
break;
397+
case LOG_SHIP_ARRIVED:
398+
case LOG_WING_ARRIVED:
399+
nprintf(("missionlog", "MISSION LOG: %s arrived at %02d:%02d\n", entry->pname, minutes, seconds));
400+
break;
401+
case LOG_SHIP_DEPARTED:
402+
case LOG_WING_DEPARTED:
403+
nprintf(("missionlog", "MISSION LOG: %s departed at %02d:%02d\n", entry->pname, minutes, seconds));
404+
break;
405+
case LOG_SHIP_DOCKED:
406+
case LOG_SHIP_UNDOCKED:
407+
nprintf(("missionlog", "MISSION LOG: %s %sdocked with %s at %02d:%02d\n", entry->pname, entry->type == LOG_SHIP_UNDOCKED ? "un" : "", entry->sname, minutes, seconds));
408+
break;
409+
case LOG_SHIP_SUBSYS_DESTROYED:
410+
nprintf(("missionlog", "MISSION LOG: %s subsystem %s destroyed at %02d:%02d\n", entry->pname, entry->sname, minutes, seconds));
411+
break;
412+
case LOG_SHIP_DISABLED:
413+
nprintf(("missionlog", "MISSION LOG: %s disabled at %02d:%02d\n", entry->pname, minutes, seconds));
414+
break;
415+
case LOG_SHIP_DISARMED:
416+
nprintf(("missionlog", "MISSION LOG: %s disarmed at %02d:%02d\n", entry->pname, minutes, seconds));
417+
break;
418+
case LOG_PLAYER_CALLED_FOR_REARM:
419+
nprintf(("missionlog", "MISSION LOG: Player %s called for rearm at %02d:%02d\n", entry->pname, minutes, seconds));
420+
break;
421+
case LOG_PLAYER_ABORTED_REARM:
422+
nprintf(("missionlog", "MISSION LOG: Player %s aborted rearm at %02d:%02d\n", entry->pname, minutes, seconds));
423+
break;
424+
case LOG_PLAYER_CALLED_FOR_REINFORCEMENT:
425+
nprintf(("missionlog", "MISSION LOG: A player called for reinforcement %s at %02d:%02d\n", entry->pname, minutes, seconds));
426+
break;
427+
case LOG_GOAL_SATISFIED:
428+
nprintf(("missionlog", "MISSION LOG: Goal %s satisfied at %02d:%02d\n", entry->pname, minutes, seconds));
429+
break;
430+
case LOG_GOAL_FAILED:
431+
nprintf(("missionlog", "MISSION LOG: Goal %s failed at %02d:%02d\n", entry->pname, minutes, seconds));
432+
break;
433+
case LOG_WAYPOINTS_DONE:
434+
nprintf(("missionlog", "MISSION LOG: %s completed waypoint path %s at %02d:%02d\n", entry->pname, entry->sname, minutes, seconds));
435+
break;
436+
case LOG_CARGO_REVEALED:
437+
nprintf(("missionlog", "MISSION LOG: %s cargo %s revealed at %02d:%02d\n", entry->pname, Cargo_names[entry->index], minutes, seconds));
438+
break;
439+
case LOG_CAP_SUBSYS_CARGO_REVEALED:
440+
nprintf(("missionlog", "MISSION LOG: %s subsystem %s cargo %s revealed at %02d:%02d\n", entry->pname, entry->sname, Cargo_names[entry->index], minutes, seconds));
441+
break;
442+
case LOG_SELF_DESTRUCTED:
443+
nprintf(("missionlog", "MISSION LOG: %s self-destructed at %02d:%02d\n", entry->pname, minutes, seconds));
444+
break;
445+
}
446+
#endif
388447
}
389448

390449
// function, used in multiplayer only, which adds an entry sent by the host of the game, into

code/mission/missionparse.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,14 +2453,6 @@ int parse_create_object_sub(p_object *p_objp)
24532453
Script_system.RunCondition(CHA_ONSHIPARRIVE, &Objects[objnum]);
24542454
Script_system.RemHookVars({"Ship", "Parent"});
24552455
}
2456-
2457-
if (Ship_info[shipp->ship_info_index].is_big_or_huge() && !brought_in_docked_wing) {
2458-
float mission_time = f2fl(Missiontime);
2459-
int minutes = (int)(mission_time / 60);
2460-
int seconds = (int)mission_time % 60;
2461-
2462-
mprintf(("%s arrived at %02d:%02d\n", shipp->ship_name, minutes, seconds));
2463-
}
24642456
}
24652457

24662458
return objnum;

code/parse/sexp.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16077,14 +16077,6 @@ void sexp_ship_create(int n)
1607716077
Script_system.RunCondition(CHA_ONSHIPARRIVE, &Objects[objnum]);
1607816078
Script_system.RemHookVars({"Ship", "Parent"});
1607916079
}
16080-
16081-
if (Game_mode & GM_IN_MISSION && sip->is_big_or_huge()) {
16082-
float mission_time = f2fl(Missiontime);
16083-
int minutes = (int)(mission_time / 60);
16084-
int seconds = (int)mission_time % 60;
16085-
16086-
mprintf(("%s created at %02d:%02d\n", shipp->ship_name, minutes, seconds));
16087-
}
1608816080
}
1608916081

1609016082
// Goober5000

code/scripting/api/libs/mission.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -939,14 +939,6 @@ ADE_FUNC(createShip,
939939
Script_system.RemHookVars({"Ship", "Parent"});
940940
}
941941

942-
if (Game_mode & GM_IN_MISSION && sip->is_big_or_huge()) {
943-
float mission_time = f2fl(Missiontime);
944-
int minutes = (int)(mission_time / 60);
945-
int seconds = (int)mission_time % 60;
946-
947-
mprintf(("%s created at %02d:%02d\n", shipp->ship_name, minutes, seconds));
948-
}
949-
950942
return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[obj_idx])));
951943
} else
952944
return ade_set_error(L, "o", l_Ship.Set(object_h()));

code/ship/ship.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8030,27 +8030,16 @@ void ship_cleanup(int shipnum, int cleanup_mode)
80308030
}
80318031
}
80328032

8033-
if (Ship_info[shipp->ship_info_index].is_big_or_huge()) {
8034-
float mission_time = f2fl(Missiontime);
8033+
#ifndef NDEBUG
8034+
// this isn't posted to the mission log, so log it here
8035+
if (cleanup_mode == SHIP_VANISHED) {
8036+
float mission_time = f2fl(Missiontime);
80358037
int minutes = (int)(mission_time / 60);
80368038
int seconds = (int)mission_time % 60;
80378039

8038-
switch (cleanup_mode) {
8039-
case SHIP_DESTROYED:
8040-
mprintf(("%s destroyed at %02d:%02d\n", shipp->ship_name, minutes, seconds));
8041-
break;
8042-
case SHIP_DEPARTED:
8043-
case SHIP_DEPARTED_WARP:
8044-
case SHIP_DEPARTED_BAY:
8045-
mprintf(("%s departed at %02d:%02d\n", shipp->ship_name, minutes, seconds));
8046-
break;
8047-
case SHIP_VANISHED:
8048-
mprintf(("%s vanished at %02d:%02d\n", shipp->ship_name, minutes, seconds));
8049-
break;
8050-
default:
8051-
break;
8052-
}
8040+
nprintf(("missionlog", "MISSION LOG: %s vanished at %02d:%02d\n", shipp->ship_name, minutes, seconds));
80538041
}
8042+
#endif
80548043

80558044
// update wingman status gauge
80568045
if ( (shipp->wing_status_wing_index >= 0) && (shipp->wing_status_wing_pos >= 0) ) {

0 commit comments

Comments
 (0)