From 91e7829b3cac1423587fa0e2c33a782f5630c1cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 3 Feb 2007 14:09:03 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=975 "SPIONIERE bringt durchwegs falsche Resulate" Falsche Schleife. Bei der Gelegenheit Spionage nach spy.c verlegt, und das ganze wegen der Sprueche die es brauchen in ein anderes Directory verschoben, auch wenn ich eigentlich meine, da gehoert es nicht hin... Jamfile-Anpassungen kommen gleich. --- src/common/gamecode/gamecode.vcproj | 3 - src/common/kernel/kernel.vcproj | 3 + src/common/kernel/reports.c | 142 +------------------------- src/common/kernel/reports.h | 1 + src/common/{gamecode => kernel}/spy.c | 142 +++++++++++++++++++++++++- src/common/kernel/spy.h | 2 +- src/common/spells/buildingcurse.c | 16 +-- src/common/spells/unitcurse.c | 22 ++-- src/config.h | 12 ++- src/eressea/eressea-lua.vcproj | 2 +- 10 files changed, 174 insertions(+), 171 deletions(-) rename src/common/{gamecode => kernel}/spy.c (83%) diff --git a/src/common/gamecode/gamecode.vcproj b/src/common/gamecode/gamecode.vcproj index 8a8790048..8fc509a57 100644 --- a/src/common/gamecode/gamecode.vcproj +++ b/src/common/gamecode/gamecode.vcproj @@ -335,9 +335,6 @@ - - diff --git a/src/common/kernel/kernel.vcproj b/src/common/kernel/kernel.vcproj index 372593fe3..0605b5dd6 100644 --- a/src/common/kernel/kernel.vcproj +++ b/src/common/kernel/kernel.vcproj @@ -391,6 +391,9 @@ + + diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index 5e29845d6..df09ce8e0 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -97,7 +97,7 @@ groupid(const struct group * g, const struct faction * f) return buf; } -static const char * +const char * report_kampfstatus(const unit * u, const struct locale * lang) { static char fsbuf[64]; @@ -802,146 +802,6 @@ spunit(struct strlist ** SP, const struct faction * f, const unit * u, int inden lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-'))); } -/* in spy steht der Unterschied zwischen Wahrnehmung des Opfers und - * Spionage des Spions */ -void -spy_message(int spy, unit *u, unit *target) -{ - const char *c; - - produceexp(u, SK_SPY, u->number); - - /* Infos: - * - Kampfstatus - * - verborgene Gegenstände: Amulette, Ringe, Phiolen, Geld - * - Partei - * - Talentinfo - * - Zaubersprüche - * - Zauberwirkungen - */ - /* mit spy=100 (magische Spionage) soll alles herausgefunden werden */ - - buf[0]='\0'; - if (spy > 99){ - /* magische Spionage */ - /* Zauberwirkungen */ - } - if (spy > 20){ - sc_mage * m = get_mage(target); - /* bei Magiern Zaubersprüche und Magiegebiet */ - if (m) { - spell_list *slist = m->spells; - boolean first = true; - - scat("Magiegebiet: "); - scat(LOC(u->faction->locale, magietypen[find_magetype(target)])); - scat(", Sprüche: "); - - for (;slist; slist=slist->next) { - spell * sp = slist->data; - if (first) { - first = false; - } else { - scat(", "); - } - scat(spell_name(sp, u->faction->locale)); - } - if (first) scat("Keine"); - scat(". "); - } - } - if (spy > 6){ - /* wahre Partei */ - scat("Partei '"); - scat(factionname(target->faction)); - scat("'. "); - } else { - /* ist die Einheit in Spionage nicht gut genug, glaubt sie die - * Parteitarnung */ - faction *fv = visible_faction(u->faction,target); - - if (fv != target->faction){ - scat("Partei '"); - scat(factionname(fv)); - scat("'. "); - } else if (!fval(target, UFL_PARTEITARNUNG)){ - scat("Partei '"); - scat(factionname(target->faction)); - scat("'. "); - } - } - if (spy > 0){ - int first = 1; - int found = 0; - skill * sv; - - scat("Talente: "); - for (sv = u->skills;sv!=u->skills+u->skill_size;++sv) { - if (sv->level>0) { - found++; - if (first == 1) { - first = 0; - } else { - scat(", "); - } - scat(skillname(sv->id, u->faction->locale)); - scat(" "); - icat(eff_skill(target, sv->id, target->region)); - } - - if (found == 0) { - scat("Keine"); - } - scat(". "); - } - - scat("Im Gepäck sind"); - { - boolean first = true; - int found = 0; - item * itm; - for (itm=target->items;itm;itm=itm->next) { - if (itm->number>0) { - resource_type * rtype = itm->type->rtype; - ++found; - if (first) { - first = false; - scat(": "); - } else { - scat(", "); - } - - if (itm->number == 1) { - scat("1 "); - scat(locale_string(u->faction->locale, resourcename(rtype, 0))); - } else { - icat(itm->number); - scat(" "); - scat(locale_string(u->faction->locale, resourcename(rtype, NMF_PLURAL))); - } - } - } - if (found == 0) { - scat(" keine verborgenen Gegenstände"); - } - scat(". "); - } - } - /* spion ist gleich gut wie Wahrnehmung Opfer */ - /* spion ist schlechter als Wahrnehmung Opfer */ - { /* immer */ - scat("Kampfstatus: "); - scat(report_kampfstatus(target, u->faction->locale)); - c = locale_string(u->faction->locale, hp_status(target)); - if (c && strlen(c)) - sprintf(buf, "%s (%s)", buf, c); - scat("."); - } - - ADDMSG(&u->faction->msgs, msg_message("spyreport", - "spy target report", u, target, strdup(buf))); -} - const struct unit * ucansee(const struct faction *f, const struct unit *u, const struct unit *x) { diff --git a/src/common/kernel/reports.h b/src/common/kernel/reports.h index 5787358c1..ab8e211b3 100644 --- a/src/common/kernel/reports.h +++ b/src/common/kernel/reports.h @@ -102,6 +102,7 @@ extern int bufunit(const struct faction * f, const struct unit * u, int indent, extern const char * reportpath(void); extern const char * trailinto(const struct region * r, const struct locale * lang); +extern const char * report_kampfstatus(const struct unit * u, const struct locale * lang); extern void reports_init(void); diff --git a/src/common/gamecode/spy.c b/src/common/kernel/spy.c similarity index 83% rename from src/common/gamecode/spy.c rename to src/common/kernel/spy.c index dfdedcd61..6a95f5f4a 100644 --- a/src/common/gamecode/spy.c +++ b/src/common/kernel/spy.c @@ -23,8 +23,6 @@ #include "eressea.h" #include "spy.h" -#include "economy.h" - /* kernel includes */ #include #include @@ -58,6 +56,145 @@ #include +/* in spy steht der Unterschied zwischen Wahrnehmung des Opfers und + * Spionage des Spions */ +void +spy_message(int spy, const unit *u, const unit *target) +{ + const char *c; + + /* Infos: + * - Kampfstatus + * - verborgene Gegenstände: Amulette, Ringe, Phiolen, Geld + * - Partei + * - Talentinfo + * - Zaubersprüche + * - Zauberwirkungen + */ + /* mit spy=100 (magische Spionage) soll alles herausgefunden werden */ + + buf[0]='\0'; + if (spy > 99){ + /* magische Spionage */ + /* Zauberwirkungen */ + } + if (spy > 20){ + sc_mage * m = get_mage(target); + /* bei Magiern Zaubersprüche und Magiegebiet */ + if (m) { + spell_list *slist = m->spells; + boolean first = true; + + scat("Magiegebiet: "); + scat(LOC(u->faction->locale, magietypen[find_magetype(target)])); + scat(", Sprüche: "); + + for (;slist; slist=slist->next) { + spell * sp = slist->data; + if (first) { + first = false; + } else { + scat(", "); + } + scat(spell_name(sp, u->faction->locale)); + } + if (first) scat("Keine"); + scat(". "); + } + } + if (spy > 6){ + /* wahre Partei */ + scat("Partei '"); + scat(factionname(target->faction)); + scat("'. "); + } else { + /* ist die Einheit in Spionage nicht gut genug, glaubt sie die + * Parteitarnung */ + faction *fv = visible_faction(u->faction,target); + + if (fv != target->faction){ + scat("Partei '"); + scat(factionname(fv)); + scat("'. "); + } else if (!fval(target, UFL_PARTEITARNUNG)){ + scat("Partei '"); + scat(factionname(target->faction)); + scat("'. "); + } + } + if (spy > 0){ + int first = 1; + int found = 0; + skill * sv; + + scat("Talente: "); + for (sv = target->skills;sv!=target->skills+target->skill_size;++sv) { + if (sv->level>0) { + found++; + if (first == 1) { + first = 0; + } else { + scat(", "); + } + scat(skillname(sv->id, u->faction->locale)); + scat(" "); + icat(eff_skill(target, sv->id, target->region)); + } + + if (found == 0) { + scat("Keine"); + } + scat(". "); + } + + scat("Im Gepäck sind"); + { + boolean first = true; + int found = 0; + item * itm; + for (itm=target->items;itm;itm=itm->next) { + if (itm->number>0) { + resource_type * rtype = itm->type->rtype; + ++found; + if (first) { + first = false; + scat(": "); + } else { + scat(", "); + } + + if (itm->number == 1) { + scat("1 "); + scat(locale_string(u->faction->locale, resourcename(rtype, 0))); + } else { + icat(itm->number); + scat(" "); + scat(locale_string(u->faction->locale, resourcename(rtype, NMF_PLURAL))); + } + } + } + if (found == 0) { + scat(" keine verborgenen Gegenstände"); + } + scat(". "); + } + } + /* spion ist gleich gut wie Wahrnehmung Opfer */ + /* spion ist schlechter als Wahrnehmung Opfer */ + { /* immer */ + scat("Kampfstatus: "); + scat(report_kampfstatus(target, u->faction->locale)); + c = locale_string(u->faction->locale, hp_status(target)); + if (c && strlen(c)) + sprintf(buf, "%s (%s)", buf, c); + scat("."); + } + + ADDMSG(&u->faction->msgs, msg_message("spyreport", + "spy target report", u, target, strdup(buf))); +} + + int spy_cmd(unit * u, struct order * ord) { @@ -89,6 +226,7 @@ spy_cmd(unit * u, struct order * ord) spychance = 0.1 + max(spy*0.05, 0.0); if (chance(spychance)) { + produceexp(u, SK_SPY, u->number); spy_message(spy, u, target); } else { ADDMSG(&u->faction->msgs, msg_message("spyfail", "spy target", u, target)); diff --git a/src/common/kernel/spy.h b/src/common/kernel/spy.h index fe4b1ad39..2c712ee46 100644 --- a/src/common/kernel/spy.h +++ b/src/common/kernel/spy.h @@ -33,7 +33,7 @@ extern int setwere_cmd(struct unit * u, struct order * ord); extern int setstealth_cmd(struct unit * u, struct order * ord); extern int spy_cmd(struct unit * u, struct order * ord); extern int sabotage_cmd(struct unit * u, struct order * ord); -extern void spy_message(int spy, struct unit *u, struct unit *target); +extern void spy_message(int spy, const struct unit *u, const struct unit *target); #define OCEAN_SWIMMER_CHANCE 0.1 #define CANAL_SWIMMER_CHANCE 0.9 diff --git a/src/common/spells/buildingcurse.c b/src/common/spells/buildingcurse.c index 20afda070..d2a6f7564 100644 --- a/src/common/spells/buildingcurse.c +++ b/src/common/spells/buildingcurse.c @@ -16,16 +16,16 @@ #include "buildingcurse.h" /* kernel includes */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* util includes */ -#include -#include +#include +#include +#include /* libc includes */ #include diff --git a/src/common/spells/unitcurse.c b/src/common/spells/unitcurse.c index 3d4b6c474..5e17211dd 100644 --- a/src/common/spells/unitcurse.c +++ b/src/common/spells/unitcurse.c @@ -16,19 +16,19 @@ #include "unitcurse.h" /* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* util includes */ -#include -#include -#include +#include +#include +#include +#include /* libc includes */ #include diff --git a/src/config.h b/src/config.h index b5992c3ac..1d2ea89f9 100644 --- a/src/config.h +++ b/src/config.h @@ -145,8 +145,10 @@ typedef struct stat stat_type; # define HAVE_SNPRINTF /* MSVC has _access, not access */ +#ifndef access # define access(f, m) _access(f, m) -# define HAVE_ACCESS +#endif +#define HAVE_ACCESS /* MSVC has _stat, not stat */ # define HAVE_STAT @@ -229,10 +231,12 @@ extern char * strdup(const char *s); /**** **** ** The Eressea boolean type ** **** ****/ -#ifdef __cplusplus - typedef int boolean; /* not bool! wrong size. */ +#if defined(WIN32) && defined(USE_MYSQL) + typedef unsigned char boolean; #else - typedef int boolean; + typedef int boolean; /* not bool! wrong size. */ +#endif +#ifndef __cplusplus # define false ((boolean)0) # define true ((boolean)!false) #endif diff --git a/src/eressea/eressea-lua.vcproj b/src/eressea/eressea-lua.vcproj index 1b3f78483..88b8287b1 100644 --- a/src/eressea/eressea-lua.vcproj +++ b/src/eressea/eressea-lua.vcproj @@ -175,7 +175,7 @@