forked from github/server
Merge branch 'develop' of https://github.com/ennorehling/eressea.git
This commit is contained in:
commit
5192ffdb60
11 changed files with 26 additions and 209 deletions
|
@ -4,7 +4,6 @@ sender = Eressea Server
|
||||||
name = Eressea
|
name = Eressea
|
||||||
report = reports
|
report = reports
|
||||||
verbose = 0
|
verbose = 0
|
||||||
lomem = 0
|
|
||||||
memcheck = 0
|
memcheck = 0
|
||||||
locales = de,en
|
locales = de,en
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,12 @@ cd tests
|
||||||
set -e
|
set -e
|
||||||
[ -z $BUILD ] && BUILD=Debug ; export BUILD
|
[ -z $BUILD ] && BUILD=Debug ; export BUILD
|
||||||
s/cmake-init
|
s/cmake-init
|
||||||
s/build
|
|
||||||
cd $ROOT
|
|
||||||
inifile
|
|
||||||
cppcheck --version
|
cppcheck --version
|
||||||
cppcheck --quiet --error-exitcode=1 src
|
cppcheck --quiet --error-exitcode=1 src
|
||||||
|
s/build
|
||||||
|
cd process
|
||||||
|
make
|
||||||
|
cd $ROOT
|
||||||
|
inifile
|
||||||
s/runtests -V
|
s/runtests -V
|
||||||
integration_tests
|
integration_tests
|
||||||
cd ../process
|
|
||||||
make
|
|
||||||
|
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ int natural_armor(unit * du)
|
||||||
static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype)
|
static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype)
|
||||||
{
|
{
|
||||||
const race *ar = u_race(au);
|
const race *ar = u_race(au);
|
||||||
int m, modifier = 0;
|
int modifier = 0;
|
||||||
if (wtype != NULL) {
|
if (wtype != NULL) {
|
||||||
if (fval(u_race(du), RCF_DRAGON)) {
|
if (fval(u_race(du), RCF_DRAGON)) {
|
||||||
static int cache;
|
static int cache;
|
||||||
|
@ -1022,6 +1022,7 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wtype->modifiers != NULL) {
|
if (wtype->modifiers != NULL) {
|
||||||
|
int m;
|
||||||
for (m = 0; wtype->modifiers[m].value; ++m) {
|
for (m = 0; wtype->modifiers[m].value; ++m) {
|
||||||
/* weapon damage for this weapon, possibly by race */
|
/* weapon damage for this weapon, possibly by race */
|
||||||
if (wtype->modifiers[m].flags & WMF_DAMAGE) {
|
if (wtype->modifiers[m].flags & WMF_DAMAGE) {
|
||||||
|
|
|
@ -41,10 +41,10 @@ int db_driver_order_save(struct order_data *od)
|
||||||
|
|
||||||
assert(od && od->_str);
|
assert(od && od->_str);
|
||||||
key.data = &recno;
|
key.data = &recno;
|
||||||
key.size = sizeof(recno);
|
key.size = key.ulen = sizeof(recno);
|
||||||
key.flags = DB_DBT_USERMEM;
|
key.flags = DB_DBT_USERMEM;
|
||||||
data.data = (void *)od->_str;
|
data.data = (void *)od->_str;
|
||||||
data.size = strlen(od->_str) + 1;
|
data.size = data.ulen = strlen(od->_str) + 1;
|
||||||
data.flags = DB_DBT_USERMEM;
|
data.flags = DB_DBT_USERMEM;
|
||||||
ret = g_dbp->put(g_dbp, NULL, &key, &data, DB_APPEND);
|
ret = g_dbp->put(g_dbp, NULL, &key, &data, DB_APPEND);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
@ -63,7 +63,7 @@ struct order_data *db_driver_order_load(int id)
|
||||||
memset(&data, 0, sizeof(DBT));
|
memset(&data, 0, sizeof(DBT));
|
||||||
recno = (db_recno_t)id;
|
recno = (db_recno_t)id;
|
||||||
key.data = &recno;
|
key.data = &recno;
|
||||||
key.size = sizeof(recno);
|
key.size = key.ulen = sizeof(recno);
|
||||||
key.flags = DB_DBT_USERMEM;
|
key.flags = DB_DBT_USERMEM;
|
||||||
ret = g_dbp->get(g_dbp, NULL, &key, &data, 0);
|
ret = g_dbp->get(g_dbp, NULL, &key, &data, 0);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
|
@ -725,11 +725,13 @@ void init_resources(void)
|
||||||
int get_money(const unit * u)
|
int get_money(const unit * u)
|
||||||
{
|
{
|
||||||
const struct resource_type *rtype = get_resourcetype(R_SILVER);
|
const struct resource_type *rtype = get_resourcetype(R_SILVER);
|
||||||
const item *i = u->items;
|
const item *i;
|
||||||
while (i && i->type->rtype != rtype) {
|
for (i = u->items; i; i = i->next) {
|
||||||
i = i->next;
|
if (i->type->rtype == rtype) {
|
||||||
|
return i->number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return i ? i->number : 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_money(unit * u, int v)
|
int set_money(unit * u, int v)
|
||||||
|
|
|
@ -114,7 +114,7 @@ int change_reservation(unit * u, const item_type * itype, int value)
|
||||||
res->type = itype;
|
res->type = itype;
|
||||||
res->value = value;
|
res->value = value;
|
||||||
}
|
}
|
||||||
else if (res && res->value + value <= 0) {
|
else if (res->value + value <= 0) {
|
||||||
*rp = res->next;
|
*rp = res->next;
|
||||||
free(res);
|
free(res);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -139,7 +139,7 @@ int set_resvalue(unit * u, const item_type * itype, int value)
|
||||||
res->type = itype;
|
res->type = itype;
|
||||||
res->value = value;
|
res->value = value;
|
||||||
}
|
}
|
||||||
else if (res && value <= 0) {
|
else if (value <= 0) {
|
||||||
*rp = res->next;
|
*rp = res->next;
|
||||||
free(res);
|
free(res);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -394,11 +394,14 @@ faction *dfindhash(int no)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct faction *dfindhash(int no) {
|
struct faction *dfindhash(int no) {
|
||||||
unit *u = deleted_units;
|
unit *u;
|
||||||
while (u && u->no != no) {
|
|
||||||
u = u->next;
|
for (u = deleted_units; u; u = u->next) {
|
||||||
|
if (u->no == no) {
|
||||||
|
return u->faction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return u ? u->faction : NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ autoseed.c
|
||||||
gmcmd.c
|
gmcmd.c
|
||||||
museum.c
|
museum.c
|
||||||
score.c
|
score.c
|
||||||
weather.c
|
|
||||||
xmas.c
|
xmas.c
|
||||||
)
|
)
|
||||||
FOREACH(_FILE ${_FILES})
|
FOREACH(_FILE ${_FILES})
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
|
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifdef WEATHER
|
|
||||||
|
|
||||||
#include <platform.h>
|
|
||||||
#include <config.h>
|
|
||||||
#include "weather.h"
|
|
||||||
|
|
||||||
/* libc includes */
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
weather *create_weather(region * r, weather_t type)
|
|
||||||
{
|
|
||||||
weather *w;
|
|
||||||
|
|
||||||
w = calloc(1, sizeof(weather));
|
|
||||||
w->center[0] = r->x;
|
|
||||||
w->center[1] = r->y;
|
|
||||||
w->type = type;
|
|
||||||
w->move[0] = (rng_int() % 3) - 1;
|
|
||||||
w->move[1] = (rng_int() % 3) - 1;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case WEATHER_STORM:
|
|
||||||
w->radius = rng_int() % 2 + 1;
|
|
||||||
break;
|
|
||||||
case WEATHER_HURRICANE:
|
|
||||||
w->radius = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
w->radius = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
addlist(&weathers, w);
|
|
||||||
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
double distance(int x1, int y1, int x2, int y2)
|
|
||||||
{
|
|
||||||
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Diese Funktion ermittelt für jede Region, welches Wetter in ihr
|
|
||||||
herrscht. Die Wettertypen sind dabei nach ihrer Reihenfolge in der
|
|
||||||
enumeration priorisiert.
|
|
||||||
|
|
||||||
- Einladen
|
|
||||||
set_weather();
|
|
||||||
- Eigentliche Auswertung
|
|
||||||
- Veränderungen des Wetters
|
|
||||||
set_weather();
|
|
||||||
- Report generieren
|
|
||||||
- Abspeichern
|
|
||||||
|
|
||||||
Diese Routine ist sehr rechenaufwendig!
|
|
||||||
*/
|
|
||||||
|
|
||||||
void set_weather(void)
|
|
||||||
{
|
|
||||||
weather_t i;
|
|
||||||
weather *w;
|
|
||||||
short x, y;
|
|
||||||
int d;
|
|
||||||
region *r;
|
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
r->weathertype = WEATHER_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MAXWEATHERS; i++) {
|
|
||||||
for (w = weathers; w; w = w->next) {
|
|
||||||
if (w->type == i) {
|
|
||||||
for (x = w->center[0] - w->radius; x <= w->center[0] + w->radius; x++) {
|
|
||||||
for (y = w->center[1] - w->radius; y <= w->center[1] + w->radius; y++) {
|
|
||||||
d = distance(w->center[0], w->center[1], x, y);
|
|
||||||
if (floor(d + 0.5) <= w->radius) {
|
|
||||||
r = findregion(x, y);
|
|
||||||
if (r) {
|
|
||||||
r->weathertype = w->type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void move_weather(void)
|
|
||||||
{
|
|
||||||
weather *w, *wnext;
|
|
||||||
region *r;
|
|
||||||
|
|
||||||
for (w = weathers; w;) {
|
|
||||||
wnext = w->next;
|
|
||||||
w->center[0] = w->center[0] + w->move[0];
|
|
||||||
w->center[1] = w->center[1] + w->move[1];
|
|
||||||
r = findregion(w->center[0], w->center[1]);
|
|
||||||
if (!r || rng_int() % 100 < 5) {
|
|
||||||
removelist(&weathers, w);
|
|
||||||
}
|
|
||||||
w = wnext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
|
||||||
static const char *copyright = "(c) Eressea PBEM 2000";
|
|
||||||
|
|
||||||
void init_weather(void)
|
|
||||||
{
|
|
||||||
fputs(copyright, stderr);
|
|
||||||
/* TODO: Initialization */
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
|
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef H_MOD_WEATHER_H
|
|
||||||
#define H_MOD_WEATHER_H
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WEATHER
|
|
||||||
# error "the weather system is disabled"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum {
|
|
||||||
WEATHER_NONE,
|
|
||||||
WEATHER_STORM,
|
|
||||||
WEATHER_HURRICANE,
|
|
||||||
MAXWEATHERS
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef unsigned char weather_t;
|
|
||||||
|
|
||||||
typedef struct weather {
|
|
||||||
struct weather *next;
|
|
||||||
weather_t type; /* Typ der Wetterzone */
|
|
||||||
int center[2]; /* Koordinaten des Zentrums */
|
|
||||||
int radius;
|
|
||||||
int move[2];
|
|
||||||
} weather;
|
|
||||||
|
|
||||||
weather *weathers;
|
|
||||||
|
|
||||||
void set_weather(void);
|
|
||||||
void move_weather(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -19,7 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "shock.h"
|
#include "shock.h"
|
||||||
|
|
||||||
#include "magic.h"
|
#include <magic.h>
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/curse.h>
|
#include <kernel/curse.h>
|
||||||
|
|
Loading…
Reference in a new issue