forked from github/server
death to static caches!
This commit is contained in:
parent
257d5c18bb
commit
2d1a13a811
|
@ -862,11 +862,9 @@ struct order *ord)
|
||||||
else {
|
else {
|
||||||
const race *irace = u_irace(u);
|
const race *irace = u_irace(u);
|
||||||
if (irace == u_race(u)) {
|
if (irace == u_race(u)) {
|
||||||
static const race *rcfailure;
|
const race *rcfailure = rc_find("smurf");
|
||||||
if (!rcfailure) {
|
if (!rcfailure) {
|
||||||
rcfailure = rc_find("smurf");
|
rcfailure = rc_find("toad");
|
||||||
if (!rcfailure)
|
|
||||||
rcfailure = rc_find("toad");
|
|
||||||
}
|
}
|
||||||
if (rcfailure) {
|
if (rcfailure) {
|
||||||
trigger *trestore = trigger_changerace(u, u_race(u), irace);
|
trigger *trestore = trigger_changerace(u, u_race(u), irace);
|
||||||
|
|
|
@ -1389,15 +1389,12 @@ void default_name(const unit *u, char name[], int len) {
|
||||||
const char * result;
|
const char * result;
|
||||||
const struct locale * lang = u->faction ? u->faction->locale : default_locale;
|
const struct locale * lang = u->faction ? u->faction->locale : default_locale;
|
||||||
if (lang) {
|
if (lang) {
|
||||||
static const char * prefix[MAXLOCALES];
|
const char * prefix;
|
||||||
int i = locale_index(lang);
|
prefix = LOC(lang, "unitdefault");
|
||||||
/*if (!prefix[i]) {*/
|
if (!prefix) {
|
||||||
prefix[i] = LOC(lang, "unitdefault");
|
prefix= parameters[P_UNIT];
|
||||||
if (!prefix[i]) {
|
|
||||||
prefix[i] = parameters[P_UNIT];
|
|
||||||
}
|
}
|
||||||
/*}*/
|
result = prefix;
|
||||||
result = prefix[i];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = parameters[P_UNIT];
|
result = parameters[P_UNIT];
|
||||||
|
|
27
src/upkeep.c
27
src/upkeep.c
|
@ -58,27 +58,28 @@ static void help_feed(unit * donor, unit * u, int *need_p)
|
||||||
*need_p = need;
|
*need_p = need;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *hunger_damage(const race *rc) {
|
||||||
|
const char * damage = get_param(rc->parameters, "hunger.damage");
|
||||||
|
if (!damage) {
|
||||||
|
damage = config_get("hunger.damage");
|
||||||
|
}
|
||||||
|
if (!damage) {
|
||||||
|
damage = "1d12+12";
|
||||||
|
}
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
static bool hunger(int number, unit * u)
|
static bool hunger(int number, unit * u)
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
int dead = 0, hpsub = 0;
|
int dead = 0, hpsub = 0;
|
||||||
int hp = u->hp / u->number;
|
int hp = u->hp / u->number;
|
||||||
static const char *damage = 0;
|
const char *damage = 0;
|
||||||
static const char *rcdamage = 0;
|
|
||||||
static const race *rc = 0;
|
|
||||||
|
|
||||||
if (!damage) {
|
damage = hunger_damage(u_race(u));
|
||||||
damage = config_get("hunger.damage");
|
|
||||||
if (damage == NULL)
|
|
||||||
damage = "1d12+12";
|
|
||||||
}
|
|
||||||
if (rc != u_race(u)) {
|
|
||||||
rcdamage = get_param(u_race(u)->parameters, "hunger.damage");
|
|
||||||
rc = u_race(u);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (number--) {
|
while (number--) {
|
||||||
int dam = dice_rand(rcdamage ? rcdamage : damage);
|
int dam = dice_rand(damage);
|
||||||
if (dam >= hp) {
|
if (dam >= hp) {
|
||||||
++dead;
|
++dead;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
double normalvariate(double mu, double sigma)
|
double normalvariate(double mu, double sigma)
|
||||||
{
|
{
|
||||||
static const double NV_MAGICCONST = 1.7155277699214135; /* STATIC_CONST: a constant */
|
static const double NV_MAGICCONST = 1.7155277699214135;
|
||||||
double z;
|
double z;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
double u1 = rng_double();
|
double u1 = rng_double();
|
||||||
|
|
|
@ -117,7 +117,7 @@ char * transliterate(char * out, size_t size, const char * in)
|
||||||
void addtoken(void ** root, const char *str, variant id)
|
void addtoken(void ** root, const char *str, variant id)
|
||||||
{
|
{
|
||||||
tnode * tk;
|
tnode * tk;
|
||||||
static const struct replace { /* STATIC_CONST: constant value */
|
static const struct replace {
|
||||||
ucs4_t ucs;
|
ucs4_t ucs;
|
||||||
const char str[3];
|
const char str[3];
|
||||||
} replace[] = {
|
} replace[] = {
|
||||||
|
|
Loading…
Reference in New Issue