forked from github/server
abgleich mit beta-1-0
This commit is contained in:
parent
70580c0ace
commit
9750b3f22b
|
@ -7,19 +7,19 @@
|
|||
CFG=attributes - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "attributes-6.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "attributes-6.mak" CFG="attributes - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
!MESSAGE "attributes - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "attributes - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
|
@ -74,7 +74,7 @@ LIB32=link.exe -lib
|
|||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
|
@ -117,6 +117,10 @@ SOURCE=.\matmod.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\otherfaction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\reduceproduction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -166,6 +170,10 @@ SOURCE=.\orcification.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\otherfaction.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\overrideroads.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -835,7 +835,7 @@ encode_region(faction * f, region * r) {
|
|||
|
||||
/* main function of the creport. creates the header and traverses all regions */
|
||||
void
|
||||
report_computer(FILE * F, faction * f)
|
||||
report_computer(FILE * F, faction * f, const time_t report_time)
|
||||
{
|
||||
int i;
|
||||
region *r;
|
||||
|
@ -857,6 +857,7 @@ report_computer(FILE * F, faction * f)
|
|||
|
||||
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
||||
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
||||
fprintf(F, "%ld;date\n", report_time);
|
||||
fprintf(F, "\"%s\";Spiel\n", global.gamename);
|
||||
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
|
||||
fprintf(F, "\"%s\";Koordinaten\n", "Hex");
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#include <time.h>
|
||||
|
||||
extern void report_computer(FILE * F, struct faction * f, const time_t report_time);
|
||||
extern void creport_cleanup(void);
|
||||
extern void creport_init(void);
|
||||
|
||||
|
|
|
@ -276,10 +276,10 @@ expandrecruit(region * r, request * recruitorders)
|
|||
if ((race[rc].ec_flags & ECF_REC_ETHEREAL)==0) p--; /* use a peasant */
|
||||
n++;
|
||||
}
|
||||
set_number(u, u->number + 1);
|
||||
u->race = rc;
|
||||
u->n++;
|
||||
}
|
||||
set_number(u, u->number + 1);
|
||||
u->race = rc;
|
||||
u->n++;
|
||||
}
|
||||
|
||||
assert(p>=0 && h>=0);
|
||||
|
@ -367,16 +367,18 @@ recruit(region * r, unit * u, strlist * S,
|
|||
}
|
||||
|
||||
recruitcost = race[u->faction->race].rekrutieren;
|
||||
pl = getplane(r);
|
||||
if (pl && fval(pl, PFL_NORECRUITS)) {
|
||||
add_message(&u->faction->msgs,
|
||||
new_message(u->faction, "error_pflnorecruit%s:command%u:unit%r:region", S->s, u, r));
|
||||
return;
|
||||
}
|
||||
if (recruitcost) {
|
||||
pl = getplane(r);
|
||||
if (pl && fval(pl, PFL_NORECRUITS)) {
|
||||
add_message(&u->faction->msgs,
|
||||
new_message(u->faction, "error_pflnorecruit%s:command%u:unit%r:region", S->s, u, r));
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_pooled(u, r, R_SILVER) < recruitcost) {
|
||||
cmistake(u, S->s, 142, MSG_EVENT);
|
||||
return;
|
||||
if (get_pooled(u, r, R_SILVER) < recruitcost) {
|
||||
cmistake(u, S->s, 142, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (nonplayer(u) || idle(u->faction)) {
|
||||
cmistake(u, S->s, 139, MSG_EVENT);
|
||||
|
@ -404,7 +406,7 @@ recruit(region * r, unit * u, strlist * S,
|
|||
cmistake(u, S->s, 156, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
n = min(n, get_pooled(u, r, R_SILVER) / recruitcost);
|
||||
if (recruitcost) n = min(n, get_pooled(u, r, R_SILVER) / recruitcost);
|
||||
|
||||
u->wants = n;
|
||||
|
||||
|
@ -764,7 +766,7 @@ dogive(region * r, unit * u, strlist * S, boolean liefere)
|
|||
|
||||
if (liefere) notfound_error = 63;
|
||||
|
||||
u2 = getunit(r, u);
|
||||
u2 = getunit(r, u->faction);
|
||||
|
||||
if (!u2 && !getunitpeasants) {
|
||||
cmistake(u, S->s, notfound_error, MSG_COMMERCE);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "laws.h"
|
||||
|
||||
#include <modules/gmcmd.h>
|
||||
#include <modules/infocmd.h>
|
||||
|
||||
#ifdef OLD_TRIGGER
|
||||
# include "old/trigger.h"
|
||||
|
@ -1324,7 +1325,7 @@ set_name(region * r, unit * u, strlist * S)
|
|||
|
||||
case P_UNIT:
|
||||
if (foreign == true) {
|
||||
unit *u2 = getunit(r, u);
|
||||
unit *u2 = getunit(r, u->faction);
|
||||
if (!u2 || !cansee(u->faction, r, u2, 0)) {
|
||||
cmistake(u, S->s, 64, MSG_EVENT);
|
||||
break;
|
||||
|
@ -2888,16 +2889,20 @@ processorders (void)
|
|||
unit *u;
|
||||
strlist *S;
|
||||
|
||||
puts(" - neue Einheiten erschaffen...");
|
||||
if (turn == 0) srand(time((time_t *) NULL));
|
||||
else srand(turn);
|
||||
|
||||
puts(" - neue Einheiten erschaffen...");
|
||||
new_units();
|
||||
|
||||
puts(" - Monster KI...");
|
||||
plan_monsters();
|
||||
set_passw(); /* und pruefe auf illegale Befehle */
|
||||
|
||||
puts(" - Defaults und Instant-Befehle...");
|
||||
setdefaults();
|
||||
instant_orders();
|
||||
|
||||
mail();
|
||||
puts(" - Altern");
|
||||
|
||||
|
@ -2930,6 +2935,11 @@ processorders (void)
|
|||
|
||||
puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)");
|
||||
do_misc(0);
|
||||
|
||||
puts(" - GM Kommandos");
|
||||
infocommands();
|
||||
gmcommands();
|
||||
|
||||
puts(" - Verlassen");
|
||||
do_leave();
|
||||
|
||||
|
@ -3029,9 +3039,6 @@ processorders (void)
|
|||
puts(" - Neue Nummern");
|
||||
renumber();
|
||||
|
||||
puts(" - GM Kommandos");
|
||||
gmcommands();
|
||||
|
||||
for (r = regions;r;r=r->next) reorder_owners(r);
|
||||
|
||||
puts(" - Attribute altern");
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
/* gamecode includes */
|
||||
#include "creation.h"
|
||||
#include "creport.h"
|
||||
#include "economy.h"
|
||||
#include "monster.h"
|
||||
#include "laws.h"
|
||||
|
@ -71,6 +72,7 @@
|
|||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1630,7 +1632,7 @@ report_building(FILE *F, const region * r, const building * b, const faction * f
|
|||
}
|
||||
|
||||
static void
|
||||
report(FILE *F, faction * f)
|
||||
report(FILE *F, faction * f, const char * pzTime)
|
||||
{
|
||||
#ifndef NEW_ITEMS
|
||||
potion_t potion;
|
||||
|
@ -1665,6 +1667,8 @@ report(FILE *F, faction * f)
|
|||
else
|
||||
printf(" - Schreibe Report\n");
|
||||
|
||||
sprintf(buf, "Report für %s, %s", global.gamename, pzTime);
|
||||
centre(F, buf, true);
|
||||
centre(F, gamedate(f->locale), true);
|
||||
rnl(F);
|
||||
sprintf(buf, "%s, %s/%s (%s)", factionname(f), LOC(f->locale, race[f->race].name[1]),
|
||||
|
@ -2536,7 +2540,9 @@ reports(void)
|
|||
FILE *shfp, *F, *BAT;
|
||||
int wants_report, wants_computer_report,
|
||||
wants_compressed, wants_bzip2;
|
||||
|
||||
time_t ltime = time(NULL);
|
||||
char * pzTime = strdup(asctime( localtime( <ime ) ));
|
||||
|
||||
nmr_warnings();
|
||||
#ifdef DMALLOC
|
||||
assert(dmalloc_verify ( NULL ));
|
||||
|
@ -2559,6 +2565,7 @@ reports(void)
|
|||
init_intervals();
|
||||
#endif
|
||||
remove_empty_units();
|
||||
log_printf("Report timestamp: %s", pzTime);
|
||||
for (f = factions; f; f = f->next) {
|
||||
attrib * a = a_find(f->attribs, &at_reportspell);
|
||||
current_faction = f;
|
||||
|
@ -2575,7 +2582,7 @@ reports(void)
|
|||
sprintf(buf, "%s/%s.nr", reportpath(), factionid(f));
|
||||
F = cfopen(buf, "wt");
|
||||
if (F) {
|
||||
report(F, f);
|
||||
report(F, f, pzTime);
|
||||
fclose(F);
|
||||
gotit = true;
|
||||
}
|
||||
|
@ -2585,7 +2592,7 @@ reports(void)
|
|||
sprintf(buf, "%s/%s.cr", reportpath(), factionid(f));
|
||||
F = cfopen(buf, "wt");
|
||||
if (F) {
|
||||
report_computer(F, f);
|
||||
report_computer(F, f, ltime);
|
||||
fclose(F);
|
||||
gotit = true;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ spy(region * r, unit * u)
|
|||
unit *target;
|
||||
int spy, observe;
|
||||
|
||||
target = getunit(r, u);
|
||||
target = getunit(r, u->faction);
|
||||
|
||||
if (!target) {
|
||||
cmistake(u, findorder(u, u->thisorder), 64, MSG_EVENT);
|
||||
|
|
|
@ -302,7 +302,7 @@ teach(region * r, unit * u)
|
|||
for (j = count; j; j--)
|
||||
getstrtoken();
|
||||
|
||||
u2 = getunit(r, u);
|
||||
u2 = getunit(r, u->faction);
|
||||
|
||||
/* Falls keine Unit gefunden, abbrechen - außer es gibt überhaupt keine
|
||||
* Unit, dann gibt es zusätzlich noch einen Fehler */
|
||||
|
|
|
@ -3444,7 +3444,7 @@ do_battle(void)
|
|||
/* Ende Fehlerbehandlung Angreifer */
|
||||
|
||||
/* attackierte Einheit ermitteln */
|
||||
u2 = getunit(r, u);
|
||||
u2 = getunit(r, u->faction);
|
||||
|
||||
/* Beginn Fehlerbehandlung */
|
||||
/* Fehler: "Die Einheit wurde nicht gefunden" */
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
/* ------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
slipthru(region * r, unit * u, const building * b)
|
||||
slipthru(const region * r, const unit * u, const building * b)
|
||||
{
|
||||
unit *u2;
|
||||
int n, o;
|
||||
|
@ -105,7 +105,7 @@ slipthru(region * r, unit * u, const building * b)
|
|||
}
|
||||
|
||||
boolean
|
||||
can_contact(region * r, unit * u, unit * u2)
|
||||
can_contact(const region * r, const unit * u, const unit * u2)
|
||||
{
|
||||
|
||||
/* hier geht es nur um die belagerung von burgen */
|
||||
|
@ -129,7 +129,7 @@ can_contact(region * r, unit * u, unit * u2)
|
|||
|
||||
|
||||
static void
|
||||
set_contact(region * r, unit * u, char try)
|
||||
set_contact(const region * r, unit * u, char try)
|
||||
{
|
||||
|
||||
/* unit u kontaktiert unit u2. Dies setzt den contact einfach auf 1 -
|
||||
|
@ -138,7 +138,7 @@ set_contact(region * r, unit * u, char try)
|
|||
* weitergegeben wird. dies wird fuer das auffinden von tempunits in
|
||||
* getnewunit () verwendet! */
|
||||
|
||||
unit *u2 = getunit(r, u);
|
||||
unit *u2 = getunitg(r, u->faction);
|
||||
|
||||
if (u2) {
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ extern char *buildingnames[MAXBUILDINGS];
|
|||
|
||||
void destroy(struct region * r, struct unit * u, const char * cmd);
|
||||
|
||||
boolean can_contact(struct region *r, struct unit *u, struct unit *u2);
|
||||
extern boolean can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
|
||||
|
||||
void do_siege(void);
|
||||
void build_road(struct region * r, struct unit * u, int size, direction_t d);
|
||||
|
|
|
@ -202,7 +202,8 @@ const char *keywords[MAXKEYWORDS] =
|
|||
"BETEN",
|
||||
"SORTIEREN",
|
||||
"JIHAD",
|
||||
"GM"
|
||||
"GM",
|
||||
"INFO"
|
||||
};
|
||||
|
||||
const char *report_options[MAX_MSG] =
|
||||
|
@ -1280,7 +1281,7 @@ unit *findunit(int n)
|
|||
}
|
||||
|
||||
unit *
|
||||
findunitg (int n, region * hint)
|
||||
findunitg (int n, const region * hint)
|
||||
{
|
||||
|
||||
/* Abfangen von Syntaxfehlern. */
|
||||
|
@ -1293,16 +1294,16 @@ findunitg (int n, region * hint)
|
|||
}
|
||||
|
||||
unit *
|
||||
getnewunit (region * r, unit * u)
|
||||
getnewunit (const region * r, const faction * f)
|
||||
{
|
||||
int n;
|
||||
n = getid();
|
||||
|
||||
return findnewunit (r, u->faction, n);
|
||||
return findnewunit (r, f, n);
|
||||
}
|
||||
|
||||
int
|
||||
read_newunitid (faction * f, region * r)
|
||||
read_newunitid (const faction * f, const region * r)
|
||||
{
|
||||
int n;
|
||||
unit *u2;
|
||||
|
@ -1317,7 +1318,7 @@ read_newunitid (faction * f, region * r)
|
|||
}
|
||||
|
||||
int
|
||||
read_unitid (faction * f, region * r)
|
||||
read_unitid (const faction * f, const region * r)
|
||||
{
|
||||
char *s;
|
||||
|
||||
|
@ -1339,13 +1340,31 @@ read_unitid (faction * f, region * r)
|
|||
/* exported symbol */
|
||||
boolean getunitpeasants;
|
||||
unit *
|
||||
getunit (region * r, unit * u)
|
||||
getunitg(const region * r, const faction * f)
|
||||
{
|
||||
int n;
|
||||
getunitpeasants = 0;
|
||||
|
||||
n = read_unitid(f, r);
|
||||
|
||||
if (n == 0) {
|
||||
getunitpeasants = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (n < 0) return 0;
|
||||
|
||||
return findunit(n);
|
||||
}
|
||||
|
||||
unit *
|
||||
getunit(const region * r, const faction * f)
|
||||
{
|
||||
int n;
|
||||
unit *u2;
|
||||
getunitpeasants = 0;
|
||||
|
||||
n = read_unitid(u->faction, r);
|
||||
n = read_unitid(f, r);
|
||||
|
||||
if (n == 0) {
|
||||
getunitpeasants = 1;
|
||||
|
|
|
@ -411,6 +411,7 @@ enum {
|
|||
K_SORT,
|
||||
K_SETJIHAD,
|
||||
K_GM, /* perform GM commands */
|
||||
K_INFO, /* set player-info */
|
||||
MAXKEYWORDS,
|
||||
NOKEYWORD = (keyword_t) - 1
|
||||
};
|
||||
|
@ -953,8 +954,9 @@ int newcontainerid(void);
|
|||
extern struct unit *createunit(struct region * r, struct faction * f, int number, race_t race);
|
||||
extern struct unit *createunitid(struct region * r1, struct faction * f, int number, race_t race, int id, const char * dname);
|
||||
extern boolean getunitpeasants;
|
||||
struct unit *getunit(struct region * r, struct unit * u);
|
||||
int read_unitid(struct faction * f, struct region * r);
|
||||
struct unit *getunitg(const struct region * r, const struct faction * f);
|
||||
struct unit *getunit(const struct region * r, const struct faction * f);
|
||||
int read_unitid(const struct faction * f, const struct region * r);
|
||||
|
||||
int isallied(const struct plane * pl, const struct faction * f, const struct faction * f2, int mode);
|
||||
int allied(const struct unit * u, const struct faction * f, int mode);
|
||||
|
@ -964,7 +966,7 @@ struct faction *findfaction_unique_id(int unique_id);
|
|||
struct faction *getfaction(void);
|
||||
|
||||
struct region *findregion(int x, int y);
|
||||
struct unit *findunitg(int n, struct region * hint);
|
||||
struct unit *findunitg(int n, const struct region * hint);
|
||||
struct unit *findunit(int n);
|
||||
|
||||
struct unit *findunitr(const struct region * r, int n);
|
||||
|
|
|
@ -13,9 +13,13 @@
|
|||
#ifndef FACTION_H
|
||||
#define FACTION_H
|
||||
|
||||
struct player;
|
||||
|
||||
typedef struct faction {
|
||||
struct faction *next;
|
||||
struct faction *nexthash;
|
||||
|
||||
struct player *owner;
|
||||
struct region *first;
|
||||
struct region *last;
|
||||
int no;
|
||||
|
|
|
@ -780,13 +780,13 @@ init_drive(void)
|
|||
for(u=r->units; u; u=u->next) {
|
||||
if(igetkeyword(u->thisorder, u->faction->locale) == K_DRIVE && !fval(u, FL_LONGACTION)) {
|
||||
boolean found = false;
|
||||
ut = getunit(r, u);
|
||||
ut = getunit(r, u->faction);
|
||||
if(!ut) {
|
||||
cmistake(u, findorder(u, u->thisorder), 64, MSG_MOVE);
|
||||
continue;
|
||||
}
|
||||
for (S = ut->orders; S; S = S->next) if (igetkeyword(S->s, u->faction->locale) == K_TRANSPORT) {
|
||||
if(getunit(r, ut) == u) {
|
||||
if(getunit(r, ut->faction) == u) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -809,11 +809,11 @@ init_drive(void)
|
|||
w = 0;
|
||||
|
||||
for (S = u->orders; S; S = S->next) if(igetkeyword(S->s, u->faction->locale) == K_TRANSPORT) {
|
||||
ut = getunit(r, u);
|
||||
ut = getunit(r, u->faction);
|
||||
if(!ut) continue;
|
||||
|
||||
if (igetkeyword(ut->thisorder, u->faction->locale) == K_DRIVE && !fval(ut, FL_LONGACTION)) {
|
||||
u2 = getunit(r, u);
|
||||
u2 = getunit(r, u->faction);
|
||||
if(u2 == u) {
|
||||
w += weight(ut);
|
||||
break;
|
||||
|
@ -1153,12 +1153,12 @@ travel(region * first, unit * u, region * next, int flucht)
|
|||
|
||||
for (S = u->orders; S; S = S->next) {
|
||||
if (igetkeyword(S->s, u->faction->locale) == K_TRANSPORT) {
|
||||
ut = getunit(first, u);
|
||||
ut = getunit(first, u->faction);
|
||||
if (ut) {
|
||||
boolean found = false;
|
||||
if (igetkeyword(ut->thisorder, u->faction->locale) == K_DRIVE
|
||||
&& !fval(ut, FL_LONGACTION)) {
|
||||
u2 = getunit(first, ut);
|
||||
u2 = getunit(first, ut->faction);
|
||||
if(u2 == u) {
|
||||
found = true;
|
||||
add_message(&u->faction->msgs, new_message(
|
||||
|
@ -1500,7 +1500,7 @@ sail(region * starting_point, unit * u, region * next_point, boolean move_on_lan
|
|||
route[step] = dir;
|
||||
last_point = current_point;
|
||||
current_point = next_point;
|
||||
tt[++step] = current_point; /* travelthrough */
|
||||
tt[step] = current_point; /* travelthrough */
|
||||
u->ship->moved = 1;
|
||||
m++;
|
||||
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
#include "player.h"
|
||||
|
||||
#include <goodies.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define PMAXHASH 1023
|
||||
|
||||
typedef struct player_hash {
|
||||
struct player * entries;
|
||||
} player_hash;
|
||||
|
||||
static player_hash * players[PMAXHASH];
|
||||
|
||||
player *
|
||||
make_player(void)
|
||||
{
|
||||
player * p = calloc(sizeof(player), 1);
|
||||
unsigned int hash;
|
||||
|
||||
for (p->id = rand();;p->id++) {
|
||||
/* if there is a hashing conflict, resolve it */
|
||||
player * pi = get_player(p->id);
|
||||
if (pi) p->id++;
|
||||
else break;
|
||||
}
|
||||
hash = p->id % PMAXHASH;
|
||||
p->nexthash = players[hash]->entries;
|
||||
players[hash]->entries = p;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
player *
|
||||
next_player(player * p)
|
||||
{
|
||||
if (p->nexthash) return p->nexthash;
|
||||
else {
|
||||
unsigned int hash = p->id % PMAXHASH;
|
||||
p = NULL;
|
||||
while (++hash!=PMAXHASH) {
|
||||
if (players[hash]->entries!=NULL) {
|
||||
p = players[hash]->entries;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
player *
|
||||
get_player(unsigned int id)
|
||||
{
|
||||
unsigned int hash = id % PMAXHASH;
|
||||
struct player * p = players[hash]->entries;
|
||||
|
||||
while (p && p->id!=id) p = p->nexthash;
|
||||
return p;
|
||||
}
|
||||
|
||||
player *
|
||||
get_players(void)
|
||||
{
|
||||
struct player * p = NULL;
|
||||
unsigned int hash = 0;
|
||||
|
||||
while (p!=NULL && hash!=PMAXHASH) {
|
||||
p = players[hash++]->entries;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
players_done(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i!=PMAXHASH;++i) {
|
||||
player * p = players[i]->entries;
|
||||
players[i]->entries = p->nexthash;
|
||||
free(p->name);
|
||||
if (p->email) free(p->email);
|
||||
if (p->info) free(p->info);
|
||||
free(p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
|
||||
struct faction;
|
||||
|
||||
typedef struct player {
|
||||
unsigned int id;
|
||||
char * name;
|
||||
char * email;
|
||||
char * info;
|
||||
struct faction * faction;
|
||||
|
||||
struct player * nexthash; /* don't use! */
|
||||
} player;
|
||||
|
||||
extern struct player * get_players(void);
|
||||
extern struct player * get_player(unsigned int id);
|
||||
extern struct player * make_player(void);
|
||||
extern struct player * next_player(struct player * p);
|
||||
|
||||
#endif
|
|
@ -1773,7 +1773,7 @@ struct racedata race[MAXRACES] =
|
|||
1.0, /* Magieresistenz (0=Normal) */
|
||||
0.0, /* Maximale Aura (1=Durchschnitt) */
|
||||
0.0, /* Auraregeneration (1=Durchschnitt) */
|
||||
1, 0, /* Rekrutierungskosten, Unterhalt pro Runde */
|
||||
0, 0, /* Rekrutierungskosten, Unterhalt pro Runde */
|
||||
10000, /* Splitsize */
|
||||
0, /* Gewicht */
|
||||
10.0, /* Multiplikator Geschwindigkeit */
|
||||
|
@ -1792,8 +1792,8 @@ struct racedata race[MAXRACES] =
|
|||
/* Sta,Spi,Ste,Str, Tak,Tar,Unt,Waf, Wag,Wah,Ste,Aus, WlK */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
},
|
||||
true, /* Nonplayer (bei Gelegenheit entfernen) */
|
||||
(RCF_SHAPESHIFTANY | RCF_SHAPESHIFT | RCF_FLY | RCF_WALK | RCF_LEARN | RCF_MOVERANDOM | RCF_ATTACKRANDOM), /* flags */
|
||||
false, /* Nonplayer (bei Gelegenheit entfernen) */
|
||||
(RCF_SHAPESHIFTANY | RCF_SHAPESHIFT | RCF_FLY | RCF_SWIM | RCF_WALK | RCF_LEARN | RCF_MOVERANDOM | RCF_ATTACKRANDOM), /* flags */
|
||||
(BF_EQUIPMENT | BF_MAGIC_EQUIPMENT), /* battle */
|
||||
(ECF_REC_ETHEREAL | ECF_REC_UNLIMITED | CANGUARD | GIVEITEM | GIVEPERSON | GIVEUNIT | GETITEM), /* economy */
|
||||
/* Vertraute für den Zauber (Gen, Ill, Tyb, Cer, Gwy, Dra) */
|
||||
|
|
|
@ -47,7 +47,6 @@ char *gamedate(const struct locale *);
|
|||
char *gamedate2(void);
|
||||
|
||||
struct summary;
|
||||
extern void report_computer(FILE * F, struct faction * f);
|
||||
extern void report_summary(struct summary * n, struct summary * o, boolean full);
|
||||
extern struct summary * make_summary(boolean count_new);
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "race.h"
|
||||
#include "attrib.h"
|
||||
#include "plane.h"
|
||||
#include "player.h"
|
||||
#include "movement.h"
|
||||
#include "alchemy.h"
|
||||
#include "region.h"
|
||||
|
@ -1539,6 +1540,48 @@ write_items(FILE *F, item *ilist)
|
|||
fputs("end", F);
|
||||
}
|
||||
|
||||
static void
|
||||
export_players(const char * path)
|
||||
{
|
||||
FILE * F;
|
||||
player * p = get_players();
|
||||
if (p==NULL) return;
|
||||
|
||||
F = cfopen(path, "w");
|
||||
if (F==NULL) return;
|
||||
|
||||
fputs("name;email;passwd;faction;info\n", F);
|
||||
while (p) {
|
||||
/* name */
|
||||
fputc('\"', F);
|
||||
if (p->name) fputs(p->name, F);
|
||||
|
||||
/* email */
|
||||
fputs("\";\"", F);
|
||||
if (p->email) fputs(p->email, F);
|
||||
else if (p->faction) fputs(p->faction->email, F);
|
||||
fputs("\";\"", F);
|
||||
|
||||
/* passwd */
|
||||
fputs("\";\"", F);
|
||||
if (p->faction) fputs(p->faction->passw, F);
|
||||
|
||||
/* faction */
|
||||
fputs("\";\"", F);
|
||||
if (p->faction) fputs(itoa36(p->faction->no), F);
|
||||
|
||||
/* info */
|
||||
fputs("\";\"", F);
|
||||
if (p->info) fputs(p->info, F);
|
||||
else if (p->faction) fputs(p->faction->banner, F);
|
||||
|
||||
fputs("\"\n", F);
|
||||
|
||||
p = next_player(p);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
|
||||
void
|
||||
writegame(char *path, char quiet)
|
||||
{
|
||||
|
@ -1554,6 +1597,10 @@ writegame(char *path, char quiet)
|
|||
strlist *S;
|
||||
const herb_type *rht;
|
||||
FILE * F;
|
||||
char playerfile[MAX_PATH];
|
||||
|
||||
sprintf(buf, "%s/%d.players", datapath(), turn);
|
||||
export_players(playerfile);
|
||||
|
||||
write_dynamictypes();
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ destroy_unit(unit * u)
|
|||
}
|
||||
|
||||
unit *
|
||||
findnewunit (region * r, faction *f, int n)
|
||||
findnewunit (const region * r, const faction *f, int n)
|
||||
{
|
||||
unit *u2;
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void usetpotionuse(struct unit * u, const struct potion_type * p); /* u benutzt
|
|||
boolean ucontact(const struct unit * u, const struct unit * u2);
|
||||
void usetcontact(struct unit * u, const struct unit * c);
|
||||
|
||||
struct unit * findnewunit (struct region * r, struct faction *f, int alias);
|
||||
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;
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
#include "gmcmd.h"
|
||||
#include "command.h"
|
||||
|
||||
#include <items/demonseye.h>
|
||||
#include <attributes/key.h>
|
||||
|
@ -19,31 +32,9 @@
|
|||
#include <attrib.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct command {
|
||||
struct command * next;
|
||||
const char * key;
|
||||
void (*perform)(const char *, unit *);
|
||||
} command;
|
||||
|
||||
static command * g_cmds;
|
||||
static tnode g_keys;
|
||||
|
||||
static void
|
||||
add_gmcommand(command ** cmds, const char * str, void(*fun)(const char*, struct unit *))
|
||||
{
|
||||
command * nc = calloc(sizeof(command), 1);
|
||||
nc->key = str;
|
||||
nc->perform = fun;
|
||||
nc->next = *cmds;
|
||||
*cmds = nc;
|
||||
|
||||
addtoken(&g_keys, str, (void*)nc);
|
||||
}
|
||||
|
||||
/**
|
||||
** at_permissions
|
||||
**/
|
||||
|
@ -112,8 +103,9 @@ make_atgmcreate(const struct item_type * itype)
|
|||
}
|
||||
|
||||
static void
|
||||
gm_create(const char * str, struct unit * u)
|
||||
gm_create(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
int i;
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (permissions) permissions = (attrib*)permissions->data.v;
|
||||
|
@ -135,8 +127,9 @@ gm_create(const char * str, struct unit * u)
|
|||
** requires: permission-key "gmterf"
|
||||
**/
|
||||
static void
|
||||
gm_terraform(const char * str, struct unit * u)
|
||||
gm_terraform(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
const struct plane * p = rplane(u->region);
|
||||
int x = rel_to_abs(p, u->faction, atoi(igetstrtoken(str)), 0);
|
||||
int y = rel_to_abs(p, u->faction, atoi(getstrtoken()), 1);
|
||||
|
@ -144,7 +137,7 @@ gm_terraform(const char * str, struct unit * u)
|
|||
region * r = findregion(x, y);
|
||||
terrain_t t;
|
||||
if (r==NULL || p!=rplane(r)) {
|
||||
mistake(u, str, "Diese Regon kann die Einheit nicht umwandeln.\n", 0);
|
||||
mistake(u, cmd, "Diese Regon kann die Einheit nicht umwandeln.\n", 0);
|
||||
return;
|
||||
} else {
|
||||
/* checking permissions */
|
||||
|
@ -162,8 +155,9 @@ gm_terraform(const char * str, struct unit * u)
|
|||
** requires: permission-key "gmtele"
|
||||
**/
|
||||
static void
|
||||
gm_teleport(const char * str, struct unit * u)
|
||||
gm_teleport(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
const struct plane * p = rplane(u->region);
|
||||
unit * to = findunit(atoi36(igetstrtoken(str)));
|
||||
int x = rel_to_abs(p, u->faction, atoi(getstrtoken()), 0);
|
||||
|
@ -171,14 +165,16 @@ gm_teleport(const char * str, struct unit * u)
|
|||
region * r = findregion(x, y);
|
||||
|
||||
if (r==NULL || p!=rplane(r)) {
|
||||
mistake(u, str, "In diese Region kann die Einheit nicht teleportieren.\n", 0);
|
||||
} if (to==NULL || (rplane(to->region)!=rplane(r) && !ucontact(to, u))) {
|
||||
mistake(u, str, "Die Einheit wurde nicht gefunden, oder sie hat uns nicht kontaktiert.\n", 0);
|
||||
mistake(u, cmd, "In diese Region kann die Einheit nicht teleportieren.\n", 0);
|
||||
} else if (to==NULL) {
|
||||
mistake(u, cmd, "Die Einheit wurde nicht gefunden.\n", 0);
|
||||
} else if (rplane(to->region)!=rplane(r) && !ucontact(to, u)) {
|
||||
mistake(u, cmd, "Die Einheit hat uns nicht kontaktiert.\n", 0);
|
||||
} else {
|
||||
/* checking permissions */
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (!permissions || !find_key((attrib*)permissions->data.v, atoi36("gmtele"))) {
|
||||
mistake(u, str, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
}
|
||||
else move_unit(to, r, NULL);
|
||||
}
|
||||
|
@ -189,23 +185,24 @@ gm_teleport(const char * str, struct unit * u)
|
|||
** requires: permission-key "gmgive"
|
||||
**/
|
||||
static void
|
||||
gm_give(const char * str, struct unit * u)
|
||||
gm_give(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
unit * to = findunit(atoi36(igetstrtoken(str)));
|
||||
int num = atoi(getstrtoken());
|
||||
const item_type * itype = finditemtype(getstrtoken(), u->faction->locale);
|
||||
|
||||
if (to==NULL || rplane(to->region) != rplane(u->region)) {
|
||||
/* unknown or in another plane */
|
||||
cmistake(u, str, 64, MSG_COMMERCE);
|
||||
mistake(u, cmd, "Die Einheit wurde nicht gefunden.\n", 0);
|
||||
} else if (itype==NULL || i_get(u->items, itype)==0) {
|
||||
/* unknown or not enough */
|
||||
mistake(u, str, "So einen Gegenstand hat die Einheit nicht.\n", 0);
|
||||
mistake(u, cmd, "So einen Gegenstand hat die Einheit nicht.\n", 0);
|
||||
} else {
|
||||
/* checking permissions */
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (!permissions || !find_key((attrib*)permissions->data.v, atoi36("gmgive"))) {
|
||||
mistake(u, str, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
}
|
||||
else {
|
||||
int i = i_get(u->items, itype);
|
||||
|
@ -223,23 +220,24 @@ gm_give(const char * str, struct unit * u)
|
|||
** requires: permission-key "gmtake"
|
||||
**/
|
||||
static void
|
||||
gm_take(const char * str, struct unit * u)
|
||||
gm_take(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
unit * to = findunit(atoi36(igetstrtoken(str)));
|
||||
int num = atoi(getstrtoken());
|
||||
const item_type * itype = finditemtype(getstrtoken(), u->faction->locale);
|
||||
|
||||
if (to==NULL || rplane(to->region) != rplane(u->region)) {
|
||||
/* unknown or in another plane */
|
||||
cmistake(u, str, 64, MSG_COMMERCE);
|
||||
mistake(u, cmd, "Die Einheit wurde nicht gefunden.\n", 0);
|
||||
} else if (itype==NULL || i_get(to->items, itype)==0) {
|
||||
/* unknown or not enough */
|
||||
mistake(u, str, "So einen Gegenstand hat die Einheit nicht.\n", 0);
|
||||
mistake(u, cmd, "So einen Gegenstand hat die Einheit nicht.\n", 0);
|
||||
} else {
|
||||
/* checking permissions */
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (!permissions || !find_key((attrib*)permissions->data.v, atoi36("gmtake"))) {
|
||||
mistake(u, str, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
}
|
||||
else {
|
||||
int i = i_get(to->items, itype);
|
||||
|
@ -257,48 +255,41 @@ gm_take(const char * str, struct unit * u)
|
|||
** requires: permission-key "gmskil"
|
||||
**/
|
||||
static void
|
||||
gm_skill(const char * str, struct unit * u)
|
||||
gm_skill(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
unit * to = findunit(atoi36(igetstrtoken(str)));
|
||||
skill_t skill = findskill(getstrtoken(), u->faction->locale);
|
||||
int num = atoi(getstrtoken());
|
||||
|
||||
if (to==NULL || rplane(to->region) != rplane(u->region)) {
|
||||
/* unknown or in another plane */
|
||||
cmistake(u, str, 64, MSG_COMMERCE);
|
||||
mistake(u, cmd, "Die Einheit wurde nicht gefunden.\n", 0);
|
||||
} else if (skill==NOSKILL || skill==SK_MAGIC || skill==SK_ALCHEMY) {
|
||||
/* unknown or not enough */
|
||||
mistake(u, str, "Dieses Talent ist unbekannt, oder kann nicht erhöht werden.\n", 0);
|
||||
mistake(u, cmd, "Dieses Talent ist unbekannt, oder kann nicht erhöht werden.\n", 0);
|
||||
} else if (num<0 || num>5000) {
|
||||
/* sanity check failed */
|
||||
mistake(u, str, "Der gewählte Wert ist nicht zugelassen.\n", 0);
|
||||
mistake(u, cmd, "Der gewählte Wert ist nicht zugelassen.\n", 0);
|
||||
} else {
|
||||
/* checking permissions */
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (!permissions || !find_key((attrib*)permissions->data.v, atoi36("gmskil"))) {
|
||||
mistake(u, str, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
}
|
||||
else {
|
||||
set_skill(to, skill, num);
|
||||
set_skill(to, skill, num*to->number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gm_command(const char * cmd, struct unit * u)
|
||||
{
|
||||
int i;
|
||||
char zText[16];
|
||||
const char * c;
|
||||
command * cm;
|
||||
static struct command * g_cmds;
|
||||
static tnode g_keys;
|
||||
|
||||
while (isspace(*cmd)) ++cmd;
|
||||
c = cmd;
|
||||
while (isalnum(*c)) ++c;
|
||||
i = min(16, c-cmd);
|
||||
strncpy(zText, cmd, i);
|
||||
zText[i]=0;
|
||||
if (findtoken(&g_keys, zText, (void**)&cm)==E_TOK_SUCCESS && cm->perform) cm->perform(++c, u);
|
||||
static void
|
||||
gm_command(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
do_command(&g_keys, data, str);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -306,13 +297,13 @@ init_gmcmd(void)
|
|||
{
|
||||
at_register(&at_gmcreate);
|
||||
at_register(&at_permissions);
|
||||
add_gmcommand(&g_cmds, "gm", &gm_command);
|
||||
add_gmcommand(&g_cmds, "terraform", &gm_terraform);
|
||||
add_gmcommand(&g_cmds, "create", &gm_create);
|
||||
add_gmcommand(&g_cmds, "give", &gm_give);
|
||||
add_gmcommand(&g_cmds, "take", &gm_take);
|
||||
add_gmcommand(&g_cmds, "teleport", &gm_teleport);
|
||||
add_gmcommand(&g_cmds, "skill", &gm_skill);
|
||||
add_command(&g_keys, &g_cmds, "gm", &gm_command);
|
||||
add_command(&g_keys, &g_cmds, "terraform", &gm_terraform);
|
||||
add_command(&g_keys, &g_cmds, "create", &gm_create);
|
||||
add_command(&g_keys, &g_cmds, "give", &gm_give);
|
||||
add_command(&g_keys, &g_cmds, "take", &gm_take);
|
||||
add_command(&g_keys, &g_cmds, "teleport", &gm_teleport);
|
||||
add_command(&g_keys, &g_cmds, "skill", &gm_skill);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -331,7 +322,7 @@ gmcommands(void)
|
|||
strlist * order;
|
||||
for (order = u->orders; order; order = order->next)
|
||||
if (igetkeyword(order->s, u->faction->locale) == K_GM) {
|
||||
gm_command(order->s, u);
|
||||
do_command(&g_keys, u, order->s);
|
||||
}
|
||||
if (u==*up) up = &u->next;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
|
||||
#include "infocmd.h"
|
||||
|
||||
#include "command.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <faction.h>
|
||||
#include <player.h>
|
||||
#include <region.h>
|
||||
#include <unit.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void
|
||||
info_email(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
const char * email = igetstrtoken(str);
|
||||
player * p = u->faction->owner;
|
||||
|
||||
if (p==NULL) {
|
||||
p = u->faction->owner = make_player();
|
||||
p->faction = u->faction;
|
||||
}
|
||||
if (p->email) free(p->email);
|
||||
if (strlen(email)) p->email = strdup(email);
|
||||
else p->email = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
info_name(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
unit * u = (unit*)data;
|
||||
const char * name = igetstrtoken(str);
|
||||
player * p = u->faction->owner;
|
||||
|
||||
if (p==NULL) {
|
||||
p = u->faction->owner = make_player();
|
||||
}
|
||||
if (p->name) free(p->name);
|
||||
if (strlen(name)) p->name = strdup(name);
|
||||
else p->name = NULL;
|
||||
}
|
||||
|
||||
static struct command * g_cmds;
|
||||
static tnode g_keys;
|
||||
|
||||
void
|
||||
infocommands(void)
|
||||
{
|
||||
region ** rp = ®ions;
|
||||
while (*rp) {
|
||||
region * r = *rp;
|
||||
unit **up = &r->units;
|
||||
while (*up) {
|
||||
unit * u = *up;
|
||||
strlist * order;
|
||||
for (order = u->orders; order; order = order->next)
|
||||
if (igetkeyword(order->s, u->faction->locale) == K_INFO) {
|
||||
do_command(&g_keys, u, order->s);
|
||||
}
|
||||
if (u==*up) up = &u->next;
|
||||
}
|
||||
if (*rp==r) rp = &r->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
info_command(const char * str, void * data, const char * cmd)
|
||||
{
|
||||
do_command(&g_keys, data, str);
|
||||
}
|
||||
|
||||
void
|
||||
info_init(void)
|
||||
{
|
||||
add_command(&g_keys, &g_cmds, "info", &info_command);
|
||||
add_command(&g_keys, &g_cmds, "email", &info_email);
|
||||
add_command(&g_keys, &g_cmds, "name", &info_name);
|
||||
}
|
||||
|
||||
void
|
||||
info_done(void)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#ifndef INFOCMD_H
|
||||
#define INFOCMD_H
|
||||
|
||||
extern void info_init(void);
|
||||
extern void info_done(void);
|
||||
extern void infocommands(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,58 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
|
||||
#include "command.h"
|
||||
|
||||
#include "umlaut.h"
|
||||
|
||||
/* libc includes */
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct command {
|
||||
struct command * next;
|
||||
const char * key;
|
||||
void (*perform)(const char *, void *, const char *);
|
||||
} command;
|
||||
|
||||
void
|
||||
add_command(struct tnode * keys, command ** cmds, const char * str, void(*fun)(const char*, void *, const char*))
|
||||
{
|
||||
command * nc = calloc(sizeof(command), 1);
|
||||
nc->key = str;
|
||||
nc->perform = fun;
|
||||
nc->next = *cmds;
|
||||
*cmds = nc;
|
||||
|
||||
addtoken(keys, str, (void*)nc);
|
||||
}
|
||||
|
||||
void
|
||||
do_command(const struct tnode * keys, void * u, const char * str)
|
||||
{
|
||||
int i;
|
||||
char zText[16];
|
||||
const char * c;
|
||||
command * cm;
|
||||
|
||||
while (isspace(*str)) ++str;
|
||||
c = str;
|
||||
while (isalnum(*c)) ++c;
|
||||
i = min(16, c-str);
|
||||
strncpy(zText, str, i);
|
||||
zText[i]=0;
|
||||
if (findtoken(keys, zText, (void**)&cm)==E_TOK_SUCCESS && cm->perform) cm->perform(++c, u, str);
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
struct command;
|
||||
struct tnode;
|
||||
|
||||
extern void add_command(struct tnode * keys, struct command ** cmds, const char * str,
|
||||
void(*fun)(const char*, void *, const char*));
|
||||
extern void do_command(const struct tnode * keys, void * u, const char * cmd);
|
||||
|
||||
#endif
|
|
@ -102,13 +102,13 @@ addtoken(tnode * root, const char* str, void * id)
|
|||
}
|
||||
|
||||
int
|
||||
findtoken(tnode * tk, const char * str, void **result)
|
||||
findtoken(const tnode * tk, const char * str, void **result)
|
||||
{
|
||||
if (*str == 0) return E_TOK_NOMATCH;
|
||||
|
||||
while (*str) {
|
||||
int index;
|
||||
tref * ref;
|
||||
const tref * ref;
|
||||
char c = *str;
|
||||
|
||||
/* if (c<'a' || c>'z') c = (char)tolower((unsigned char)c); */
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct tnode {
|
|||
void * id;
|
||||
} tnode;
|
||||
|
||||
int findtoken(struct tnode * tk, const char * str, void** result);
|
||||
int findtoken(const struct tnode * tk, const char * str, void** result);
|
||||
void addtoken(struct tnode * root, const char* str, void * id);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,8 +33,8 @@ INCLUDES += \
|
|||
|
||||
LIBNAMES = \
|
||||
e-triggers \
|
||||
e-modules \
|
||||
e-gamecode \
|
||||
e-modules \
|
||||
e-kernel \
|
||||
e-items \
|
||||
e-spells \
|
||||
|
|
|
@ -150,6 +150,10 @@ SOURCE=..\common\modules\museum.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\attributes\otherfaction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\modules\score.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -1531,6 +1535,10 @@ SOURCE=.\main.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\attributes\otherfaction.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\spells.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Loading…
Reference in New Issue