summaryrefslogtreecommitdiff
path: root/src/uqm/dummy.c
blob: 9a95c362de6cdbe74eb7de122a590a75c8c96b27 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//Copyright Paul Reiche, Fred Ford. 1992-2002

/*
 *  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.
 */

/*
 * This file seems to be a collection of functions that don't do
 * much.
 */

#include "dummy.h"

#include "coderes.h"
#include "globdata.h"
#include "races.h"

#include "libs/compiler.h"
#include "libs/log.h"
#include "libs/memlib.h"

#include <stdlib.h>
#include <ctype.h>


typedef struct
{
	RACE_DESC data _ALIGNED_ANY;
} CODERES_STRUCT;

typedef enum
{
	ANDROSYN_CODE_RES,
	ARILOU_CODE_RES,
	BLACKURQ_CODE_RES,
	CHENJESU_CODE_RES,
	CHMMR_CODE_RES,
	DRUUGE_CODE_RES,
	HUMAN_CODE_RES,
	ILWRATH_CODE_RES,
	MELNORME_CODE_RES,
	MMRNMHRM_CODE_RES,
	MYCON_CODE_RES,
	ORZ_CODE_RES,
	PKUNK_CODE_RES,
	SHOFIXTI_CODE_RES,
	SLYLANDR_CODE_RES,
	SPATHI_CODE_RES,
	SUPOX_CODE_RES,
	SYREEN_CODE_RES,
	THRADD_CODE_RES,
	UMGAH_CODE_RES,
	URQUAN_CODE_RES,
	UTWIG_CODE_RES,
	VUX_CODE_RES,
	YEHAT_CODE_RES,
	ZOQFOT_CODE_RES,

	SAMATRA_CODE_RES,
	SIS_CODE_RES,
	PROBE_CODE_RES
} ShipCodeRes;

typedef RACE_DESC *(*RaceDescInitFunc)(void);

static RaceDescInitFunc
CodeResToInitFunc(ShipCodeRes res)
{
	switch (res)
	{
		case ANDROSYN_CODE_RES: return &init_androsynth;
		case ARILOU_CODE_RES: return &init_arilou;
		case BLACKURQ_CODE_RES: return &init_black_urquan;
		case CHENJESU_CODE_RES: return &init_chenjesu;
		case CHMMR_CODE_RES: return &init_chmmr;
		case DRUUGE_CODE_RES: return &init_druuge;
		case HUMAN_CODE_RES: return &init_human;
		case ILWRATH_CODE_RES: return &init_ilwrath;
		case MELNORME_CODE_RES: return &init_melnorme;
		case MMRNMHRM_CODE_RES: return &init_mmrnmhrm;
		case MYCON_CODE_RES: return &init_mycon;
		case ORZ_CODE_RES: return &init_orz;
		case PKUNK_CODE_RES: return &init_pkunk;
		case SHOFIXTI_CODE_RES: return &init_shofixti;
		case SLYLANDR_CODE_RES: return &init_slylandro;
		case SPATHI_CODE_RES: return &init_spathi;
		case SUPOX_CODE_RES: return &init_supox;
		case SYREEN_CODE_RES: return &init_syreen;
		case THRADD_CODE_RES: return &init_thraddash;
		case UMGAH_CODE_RES: return &init_umgah;
		case URQUAN_CODE_RES: return &init_urquan;
		case UTWIG_CODE_RES: return &init_utwig;
		case VUX_CODE_RES: return &init_vux;
		case YEHAT_CODE_RES: return &init_yehat;
		case ZOQFOT_CODE_RES: return &init_zoqfotpik;
		case SAMATRA_CODE_RES: return &init_samatra;
		case SIS_CODE_RES: return &init_sis;
		case PROBE_CODE_RES: return &init_probe;
		default:
		{
			log_add (log_Warning, "Unknown SHIP identifier '%d'", res);
			return NULL;
		}
	}
}

static void
GetCodeResData (const char *ship_id, RESOURCE_DATA *resdata)
{
	BYTE which_res;
	void *hData;

	which_res = atoi (ship_id);
	hData = HMalloc (sizeof (CODERES_STRUCT));
	if (hData)
	{
		RaceDescInitFunc initFunc = CodeResToInitFunc (which_res);
		RACE_DESC *RDPtr = (initFunc == NULL) ? NULL : (*initFunc)();
		if (RDPtr == 0)
		{
			HFree (hData);
			hData = 0;
		}
		else
		{
			CODERES_STRUCT *cs;

			cs = (CODERES_STRUCT *) hData;
			cs->data = *RDPtr;  // Structure assignment.
		}
	}
	resdata->ptr = hData;
}

static BOOLEAN
_ReleaseCodeResData (void *data)
{
	HFree (data);
	return TRUE;
}

BOOLEAN
InstallCodeResType ()
{
	return (InstallResTypeVectors ("SHIP",
			GetCodeResData, _ReleaseCodeResData, NULL));
}


void *
LoadCodeResInstance (RESOURCE res)
{
	void *hData;

	hData = res_GetResource (res);
	if (hData)
		res_DetachResource (res);

	return hData;
}


BOOLEAN
DestroyCodeRes (void *hCode)
{
	HFree (hCode);
	return TRUE;
}


void*
CaptureCodeRes (void *hCode, void *pData, void **ppLocData)
{
	CODERES_STRUCT *cs;

	if (hCode == NULL)
	{
		log_add (log_Fatal, "dummy.c::CaptureCodeRes() hCode==NULL! FATAL!");
		return(NULL);
	}

	cs = (CODERES_STRUCT *) hCode;
	*ppLocData = &cs->data;

	(void) pData;  /* Satisfying compiler (unused parameter) */
	return cs;
}


void *
ReleaseCodeRes (void *CodeRef)
{
	return CodeRef;
}