From ec761909a9e5a04b5048c33fbdfe2891a9d1e5d0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 25 Nov 2002 16:53:10 +0000 Subject: [PATCH] Removed some warnings about type conversion. --- src/common/gamecode/economy.c | 6 +++--- src/common/kernel/unit.c | 21 +++++++++++++++++++-- src/common/kernel/unit.h | 4 ++-- src/res/races.xml | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index a541afdb5..79137b2af 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -485,11 +485,11 @@ add_give(unit * u, unit * u2, int n, const resource_type * rtype, const char * c assert(rtype); add_message(&u->faction->msgs, msg_message("give", "unit target resource amount", - u, u2?ucansee(u->faction, u2, &u_unknown):&u_peasants, rtype, n)); + u, u2?ucansee(u->faction, u2, u_unknown()):u_peasants(), rtype, n)); if (u2) { add_message(&u2->faction->msgs, msg_message("give", "unit target resource amount", - ucansee(u2->faction, u, &u_unknown), u2, rtype, n)); + ucansee(u2->faction, u, u_unknown()), u2, rtype, n)); } } } @@ -884,7 +884,7 @@ dogive(region * r, unit * u, strlist * S, boolean liefere, int mode) if (u->faction != u2->faction) { add_message(&u2->faction->msgs, msg_message("givecommand", "unit receipient", - ucansee(u2->faction, u, &u_unknown), u2)); + ucansee(u2->faction, u, u_unknown()), u2)); } return; } diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index b44d10569..ffc658302 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -55,8 +55,25 @@ int demonfix = 0; /* ------------------------------------------------------------- */ -const unit u_peasants = { NULL, NULL, NULL, NULL, NULL, 2, "die Bauern" }; -const unit u_unknown = { NULL, NULL, NULL, NULL, NULL, 1, "eine unbekannte Einheit" }; +const unit * +u_peasants(void) +{ + static unit peasants = { NULL, NULL, NULL, NULL, NULL, 2, NULL }; + if (peasants.name==NULL) { + peasants.name = strdup("die Bauern"); + } + return &peasants; +} + +const unit * +u_unknown(void) +{ + static unit unknown = { NULL, NULL, NULL, NULL, NULL, 1, NULL }; + if (unknown.name==NULL) { + unknown.name =strdup("eine unbekannte Einheit"); + } + return &unknown; +} #define DMAXHASH 8191 typedef struct dead { diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index dbe45e0c8..d99f55849 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -105,8 +105,8 @@ void usetcontact(struct unit * u, const struct unit * c); struct unit * findnewunit (const struct region * r, const struct faction *f, int alias); #define upotions(u) fval(u, FL_POTIONS) -extern const struct unit u_peasants; -extern const struct unit u_unknown; +extern const struct unit * u_peasants(void); +extern const struct unit * u_unknown(void); extern struct unit * udestroy; diff --git a/src/res/races.xml b/src/res/races.xml index 8aaed1aa1..32485741e 100644 --- a/src/res/races.xml +++ b/src/res/races.xml @@ -183,7 +183,7 @@ - +