Skip to content

Commit 10b3571

Browse files
committed
improve and expand logging
1 parent f8c41ac commit 10b3571

File tree

5 files changed

+64
-52
lines changed

5 files changed

+64
-52
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
@@ -2458,14 +2458,6 @@ int parse_create_object_sub(p_object *p_objp)
24582458
Script_system.RunCondition(CHA_ONSHIPARRIVE, &Objects[objnum]);
24592459
Script_system.RemHookVars({"Ship", "Parent"});
24602460
}
2461-
2462-
if (Ship_info[shipp->ship_info_index].is_big_or_huge() && !brought_in_docked_wing) {
2463-
float mission_time = f2fl(Missiontime);
2464-
int minutes = (int)(mission_time / 60);
2465-
int seconds = (int)mission_time % 60;
2466-
2467-
mprintf(("%s arrived at %02d:%02d\n", shipp->ship_name, minutes, seconds));
2468-
}
24692461
}
24702462

24712463
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: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8031,26 +8031,13 @@ void ship_cleanup(int shipnum, int cleanup_mode)
80318031
}
80328032

80338033
#ifndef NDEBUG
8034-
{
8035-
float mission_time = f2fl(Missiontime);
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);
80368037
int minutes = (int)(mission_time / 60);
80378038
int seconds = (int)mission_time % 60;
80388039

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

@@ -10155,16 +10142,6 @@ int ship_create(matrix* orient, vec3d* pos, int ship_type, const char* ship_name
1015510142

1015610143
shipp->time_created = Missiontime;
1015710144

10158-
#ifndef NDEBUG
10159-
if (!Fred_running) {
10160-
float mission_time = f2fl(Missiontime);
10161-
int minutes = (int)(mission_time / 60);
10162-
int seconds = (int)mission_time % 60;
10163-
10164-
mprintf(("%s created at %02d:%02d\n", shipp->ship_name, minutes, seconds));
10165-
}
10166-
#endif
10167-
1016810145
return objnum;
1016910146
}
1017010147

0 commit comments

Comments
 (0)