CleanUp
This commit is contained in:
parent
49fad13971
commit
0453d5ae6b
7 changed files with 14 additions and 39 deletions
src
|
@ -117,8 +117,6 @@ struct _campaign_chapter_ {
|
|||
** Campaign structure.
|
||||
*/
|
||||
typedef struct _campaign_ {
|
||||
const void* OType; ///< Object type (future extensions)
|
||||
|
||||
char* Ident; ///< Unique identifier
|
||||
char* Name; ///< Campaign name
|
||||
int Players; ///< Campaign for X players
|
||||
|
|
|
@ -51,10 +51,6 @@
|
|||
**
|
||||
** The construction structure members:
|
||||
**
|
||||
** Construction::OType
|
||||
**
|
||||
** Object type (future extensions).
|
||||
**
|
||||
** Construction::Ident
|
||||
**
|
||||
** Unique identifier of the construction, used to reference it in
|
||||
|
@ -125,7 +121,6 @@ typedef struct _construction_frame_ {
|
|||
|
||||
/// Construction shown during construction of a building
|
||||
typedef struct _construction_ {
|
||||
const void* OType; ///< Object type (future extensions)
|
||||
char* Ident; ///< construction identifier
|
||||
struct {
|
||||
char* File; ///< sprite file
|
||||
|
@ -152,7 +147,7 @@ typedef struct _construction_ {
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
extern const char ConstructionType[]; ///< Construction type
|
||||
//extern const char ConstructionType[]; ///< Construction type
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
|
|
@ -52,10 +52,6 @@
|
|||
**
|
||||
** The cursor-type structure members:
|
||||
**
|
||||
** CursorType::OType
|
||||
**
|
||||
** Object type (future extensions).
|
||||
**
|
||||
** CursorType::Ident
|
||||
**
|
||||
** Unique identifier of the cursor, used to reference it in config
|
||||
|
@ -137,7 +133,6 @@ typedef struct _cursor_type_ CursorType;
|
|||
|
||||
/// Private type which specifies the cursor-type
|
||||
struct _cursor_type_ {
|
||||
const void* OType; ///< Object type (future extensions)
|
||||
char* Ident; ///< Identifier to reference it
|
||||
char* Race; ///< Race name
|
||||
|
||||
|
@ -170,8 +165,8 @@ typedef enum _cursor_states_ {
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
extern const char CursorTypeType[]; ///< cursor-type type
|
||||
extern CursorType* Cursors; ///< cursor-types description
|
||||
extern int CursorMax; ///< Number of cursor.
|
||||
|
||||
extern CursorStates CursorState; ///< current cursor state (point,...)
|
||||
extern int CursorAction; ///< action for selection
|
||||
|
|
|
@ -52,10 +52,6 @@
|
|||
**
|
||||
** The missile-type structure members:
|
||||
**
|
||||
** MissileType::OType
|
||||
**
|
||||
** Object type (future extensions).
|
||||
**
|
||||
** MissileType::Ident
|
||||
**
|
||||
** Unique identifier of the missile-type, used to reference it in
|
||||
|
|
|
@ -49,11 +49,6 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Construction type definition
|
||||
*/
|
||||
const char ConstructionType[] = "construction";
|
||||
|
||||
/**
|
||||
** Constructions.
|
||||
*/
|
||||
|
@ -295,7 +290,6 @@ static int CclDefineConstruction(lua_State* l)
|
|||
Constructions[i + 1] = NULL;
|
||||
construction = Constructions[i];
|
||||
}
|
||||
construction->OType = ConstructionType;
|
||||
construction->Ident = str;
|
||||
|
||||
//
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
char* ClickMissile; ///< FIXME:docu
|
||||
char* DamageMissile; ///< FIXME:docu
|
||||
|
||||
|
@ -454,7 +453,7 @@ static int CclDefineCursor(lua_State* l)
|
|||
ct = NULL;
|
||||
i = 0;
|
||||
if (Cursors) {
|
||||
for (; Cursors[i].OType; ++i) {
|
||||
for (; i < CursorMax; ++i) {
|
||||
//
|
||||
// Race not same, not found.
|
||||
//
|
||||
|
@ -475,12 +474,9 @@ static int CclDefineCursor(lua_State* l)
|
|||
// Not found, make a new slot.
|
||||
//
|
||||
if (!ct) {
|
||||
ct = calloc(i + 2, sizeof(CursorType));
|
||||
memcpy(ct, Cursors, sizeof(CursorType) * i);
|
||||
free(Cursors);
|
||||
Cursors = ct;
|
||||
CursorMax++;
|
||||
Cursors = realloc(Cursors, CursorMax * sizeof (*Cursors));
|
||||
ct = &Cursors[i];
|
||||
ct->OType = CursorTypeType;
|
||||
ct->Ident = strdup(name);
|
||||
ct->Race = race ? strdup(race) : NULL;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
/**
|
||||
** Cursor-type type definition
|
||||
*/
|
||||
const char CursorTypeType[] = "cursor-type";
|
||||
int CursorMax = 0; ///< Number of cursor.
|
||||
|
||||
/**
|
||||
** Define cursor-types.
|
||||
|
@ -122,7 +122,7 @@ void LoadCursors(const char* race)
|
|||
//
|
||||
// Load the graphics
|
||||
//
|
||||
for (i = 0; Cursors[i].OType; ++i) {
|
||||
for (i = 0; i < CursorMax; ++i) {
|
||||
//
|
||||
// Only load cursors of this race or universal cursors.
|
||||
//
|
||||
|
@ -148,14 +148,14 @@ void LoadCursors(const char* race)
|
|||
*/
|
||||
CursorType* CursorTypeByIdent(const char* ident)
|
||||
{
|
||||
CursorType* cursortype;
|
||||
int i; // iterator.
|
||||
|
||||
for (cursortype = Cursors; cursortype->OType; ++cursortype) {
|
||||
if (strcmp(cursortype->Ident, ident)) {
|
||||
for (i = 0; i < CursorMax; i++) {
|
||||
if (strcmp(Cursors[i].Ident, ident)) {
|
||||
continue;
|
||||
}
|
||||
if (!cursortype->Race || cursortype->G) {
|
||||
return cursortype;
|
||||
if (!Cursors[i].Race || Cursors[i].G) {
|
||||
return Cursors + i;
|
||||
}
|
||||
}
|
||||
DebugPrint("Cursor `%s' not found, please check your code.\n" _C_ ident);
|
||||
|
@ -406,13 +406,14 @@ void CleanCursors(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; Cursors[i].OType; ++i) {
|
||||
for (i = 0; i < CursorMax; ++i) {
|
||||
FreeGraphic(Cursors[i].G);
|
||||
free(Cursors[i].Ident);
|
||||
free(Cursors[i].Race);
|
||||
}
|
||||
free(Cursors);
|
||||
Cursors = NULL;
|
||||
CursorMax = 0;
|
||||
|
||||
CursorBuilding = 0;
|
||||
GameCursor = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue