-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamedata.c
153 lines (124 loc) · 3.13 KB
/
gamedata.c
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (C) 1995 Ronny Wester
Copyright (C) 2003 Jeremy Chin
Copyright (C) 2003-2007 Lucas Martin-King
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------
gamedata.c - game data related stuff
Author: $Author: lmartinking $
Rev: $Revision: 250 $
URL: $HeadURL: svn://svn.icculus.org/cdogs-sdl/trunk/src/gamedata.c $
ID: $Id: gamedata.c 250 2007-07-06 16:38:43Z lmartinking $
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "SDL.h"
#include "gamedata.h"
#include "actors.h"
#include "defs.h"
#include "keyboard.h"
#include "input.h"
#include "utils.h"
struct PlayerData gPlayer1Data = {
"Player 1", 0, SHADE_BLUE, SHADE_BLUE, SHADE_BLUE, 0, 0,
3, {GUN_SHOTGUN, GUN_MG, GUN_FRAGGRENADE},
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KEYBOARD,
{SDLK_LEFT, SDLK_RIGHT, SDLK_UP, SDLK_DOWN,
SDLK_RSHIFT, SDLK_RETURN}
};
struct PlayerData gPlayer2Data = {
"Player 2", 1, SHADE_RED, SHADE_RED, SHADE_RED, 2, 0,
3, {GUN_POWERGUN, GUN_FLAMER, GUN_GRENADE},
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KEYBOARD,
{keyKeypad4, keyKeypad6, keyKeypad8, keyKeypad2, keyKeypad0,
keyKeypadEnter}
};
struct GameOptions gOptions = {
0,
1,
0, 0,
0,
0,
0,
0,
COPY_REPMOVSD,
0,
0,
0, 0,
keyTab,
100,
100,
100,
100,
0
};
struct CampaignOptions gCampaign = {
NULL, 0, 0
};
struct MissionOptions gMission;
struct SongDef *gGameSongs = NULL;
struct SongDef *gMenuSongs = NULL;
void AddSong(struct SongDef **songList, const char *path)
{
struct SongDef *s;
s = sys_mem_alloc(sizeof(struct SongDef));
strcpy(s->path, path);
s->next = *songList;
*songList = s;
}
void ShiftSongs(struct SongDef **songList)
{
struct SongDef **h;
if (!*songList || !(*songList)->next)
return;
h = songList;
while (*h)
h = &(*h)->next;
*h = *songList;
*songList = (*songList)->next;
(*h)->next = NULL;
}
void FreeSongs(struct SongDef **songList)
{
struct SongDef *s;
while (*songList) {
s = *songList;
*songList = s->next;
free(s);
}
}
void LoadSongs(const char *path, struct SongDef **songList)
{
FILE *f;
char s[100], *p;
debug("LoadSongs path: %s\n", path);
f = fopen(path, "r");
if (f) {
while (fgets(s, sizeof(s), f)) {
p = s + strlen(s);
while (p >= s && !isgraph(*p))
*p-- = 0;
if (s[0]) {
debug("Added song: %s\n", s);
AddSong(songList, s);
}
}
fclose(f);
}
}