| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
#include "gamedata.h" |
| 50 |
|
| 51 |
#include <assert.h> |
| 52 |
#include <stdlib.h> |
| 53 |
#include <stdio.h> |
| 54 |
#include <string.h> |
| 55 |
#include <ctype.h> |
| 56 |
|
| 57 |
#include <tinydir/tinydir.h> |
| 58 |
|
| 59 |
#include "actors.h" |
| 60 |
#include "config.h" |
| 61 |
#include "defs.h" |
| 62 |
#include "keyboard.h" |
| 63 |
#include "log.h" |
| 64 |
#include "music.h" |
| 65 |
#include "objs.h" |
| 66 |
#include "pickup.h" |
| 67 |
#include "player_template.h" |
| 68 |
#include "quick_play.h" |
| 69 |
#include "sys_config.h" |
| 70 |
#include "utils.h" |
| 71 |
|
| 72 |
Campaign gCampaign; |
| 73 |
|
| 74 |
struct MissionOptions gMission; |
| 75 |
|
| 76 |
struct SongDef *gGameSongs = NULL; |
| 77 |
struct SongDef *gMenuSongs = NULL; |
| 78 |
|
| 79 |
|
| 80 |
bool CampaignLoad(Campaign *co, const CampaignEntry *entry) |
| 81 |
{ |
| 82 |
CASSERT(!co->IsLoaded, "loading campaign without unloading last one"); |
| 83 |
|
| 84 |
const GameMode mode = co->Entry.Mode; |
| 85 |
CampaignEntryCopy(&co->Entry, entry); |
| 86 |
co->Entry.Mode = mode; |
| 87 |
CampaignSettingInit(&co->Setting); |
| 88 |
if (entry->Mode == GAME_MODE_QUICK_PLAY) |
| 89 |
{ |
| 90 |
SetupQuickPlayCampaign(&co->Setting, false); |
| 91 |
co->IsLoaded = true; |
| 92 |
} |
| 93 |
else |
| 94 |
{ |
| 95 |
|
| 96 |
char buf[CDOGS_PATH_MAX]; |
| 97 |
GetDataFilePath(buf, entry->Path); |
| 98 |
if (MapNewLoad(buf, &co->Setting)) |
| 99 |
{ |
| 100 |
LOG(LM_MAIN, LL_ERROR, "failed to load campaign %s!", buf); |
| 101 |
CASSERT(false, "Failed to load campaign"); |
| 102 |
} |
| 103 |
else |
| 104 |
{ |
| 105 |
co->IsLoaded = true; |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
if (co->IsLoaded) |
| 110 |
{ |
| 111 |
LOG(LM_MAIN, LL_INFO, "loaded campaign/dogfight"); |
| 112 |
} |
| 113 |
return co->IsLoaded; |
| 114 |
} |
| 115 |
void CampaignUnload(Campaign *co) |
| 116 |
{ |
| 117 |
co->MissionIndex = 0; |
| 118 |
co->IsLoaded = false; |
| 119 |
co->IsClient = false; |
| 120 |
co->OptionsSet = false; |
| 121 |
co->IsComplete = false; |
| 122 |
gCampaign.IsQuit = false; |
| 123 |
CampaignEntryTerminate(&co->Entry); |
| 124 |
} |
| 125 |
|
| 126 |
void MissionOptionsInit(struct MissionOptions *mo) |
| 127 |
{ |
| 128 |
memset(mo, 0, sizeof *mo); |
| 129 |
CArrayInit(&mo->Weapons, sizeof(WeaponClass *)); |
| 130 |
} |
| 131 |
void MissionOptionsTerminate(struct MissionOptions *mo) |
| 132 |
{ |
| 133 |
ActorsTerminate(); |
| 134 |
ObjsTerminate(); |
| 135 |
MobObjsTerminate(); |
| 136 |
PickupsTerminate(); |
| 137 |
ParticlesTerminate(&gParticles); |
| 138 |
WatchesTerminate(); |
| 139 |
CA_FOREACH(PlayerData, p, gPlayerDatas) |
| 140 |
p->ActorUID = -1; |
| 141 |
CA_FOREACH_END() |
| 142 |
gMission.HasStarted = false; |
| 143 |
gMission.HasBegun = false; |
| 144 |
CArrayTerminate(&mo->Weapons); |
| 145 |
|
| 146 |
memset(mo, 0, sizeof *mo); |
| 147 |
} |