making the old eressea binary run on x64:

- normalvariate fix.
- familiars again
- invalid assert
- forgot init_reports
This commit is contained in:
Enno Rehling 2006-02-09 22:20:28 +00:00
parent e02a7afb78
commit 589b1b036a
5 changed files with 27 additions and 40 deletions

View File

@ -1436,8 +1436,13 @@ randomevents(void)
int n = itm->number;
double k = n*rot_chance/100.0;
if (fval(itm->type, ITF_HERB)) {
n = (int)(min(n, normalvariate(k, k/4)));
i_change(itmp, itm->type, -n);
double nv = normalvariate(k, k/4);
int inv = (int)nv;
int delta = min(n, inv);
if (inv<0) {
nv = normalvariate(k, k/4);
}
i_change(itmp, itm->type, -delta);
}
if (itm==*itmp) itmp=&itm->next;
}

View File

@ -148,10 +148,10 @@ register_bordertype(border_type * type)
border_type *
find_bordertype(const char * name)
{
border_type * bt = bordertypes;
border_type * bt = bordertypes;
while (bt && strcmp(bt->__name, name)) bt = bt->next;
return bt;
while (bt && strcmp(bt->__name, name)) bt = bt->next;
return bt;
}
void
@ -176,7 +176,6 @@ b_read(border * b, FILE *f)
void
b_write(const border * b, FILE *f)
{
assert(sizeof(int)==sizeof(b->data));
switch (b->type->datatype) {
case VAR_NONE:
case VAR_INT:

View File

@ -535,8 +535,7 @@ select_familiar(const race * magerace, magic_t magiegebiet)
retval = magerace->familiars[magiegebiet];
}
assert (retval!=NULL);
if (retval->init_familiar!=NULL) {
if (retval!=NULL && retval->init_familiar!=NULL) {
return NULL;
}
return retval;

View File

@ -26,9 +26,10 @@
#include <assert.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <ctype.h>
#define drand() (((double)rand())/(double)RAND_MAX)
#define drand() ((rand()%RAND_MAX)/(double)RAND_MAX)
#define M_PIl 3.1415926535897932384626433832795029L /* pi */
static double nv_next;
@ -39,37 +40,17 @@ static char valid_next = 0;
double
normalvariate(double mu, double sigma)
{
double x2pi, g2rad, z;
double t1, t2;
double fac=1;
static double mu_alt, sigma_alt;
if(mu < 10) {
fac=0.01;
mu*=100;
sigma*=100;
static double NV_MAGICCONST = 1.7155277699214135;
double z;
for (;;) {
double u1 = drand();
double u2 = 1.0 - drand();
z = NV_MAGICCONST*(u1-0.5)/u2;
if (z*z/4.0 <= -log(u2)) {
break;
}
}
if(mu_alt!=mu || sigma_alt!= sigma)
valid_next=0;
mu_alt=mu;
sigma_alt=sigma;
if (valid_next == 0) {
x2pi = drand() * 2.0L * M_PIl;
t1 = drand();
t1 = 1.0 - t1;
t2 = log(t1);
g2rad = sqrt(-2.0 * t2);
z = cos(x2pi) * g2rad;
nv_next = sin(x2pi) * g2rad;
valid_next = 1;
} else {
z = nv_next;
valid_next = 0;
}
return (fac*(mu + z*sigma)); /* mu thorin */
return mu+z*sigma;
}
int

View File

@ -271,7 +271,10 @@ processturn(char *filename)
}
score();
update_guards();
if (!noreports) reports();
if (!noreports) {
init_reports();
reports();
}
free_units();
puts(" - Beseitige leere Parteien");
remove_empty_factions(true);