abgleich beta->dev version

This commit is contained in:
Enno Rehling 2001-05-11 20:19:22 +00:00
parent cfdbc32470
commit b737838e60
14 changed files with 231 additions and 29 deletions

View File

@ -1,6 +1,4 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -29,6 +27,7 @@
#include <triggers/changerace.h>
#include <triggers/createcurse.h>
#include <triggers/createunit.h>
#include <triggers/gate.h>
#include <triggers/giveitem.h>
#include <triggers/killunit.h>
#include <triggers/removecurse.h>
@ -50,6 +49,7 @@ register_triggers(void)
tt_register(&tt_changerace);
tt_register(&tt_createcurse);
tt_register(&tt_createunit);
tt_register(&tt_gate);
tt_register(&tt_giveitem);
tt_register(&tt_killunit);
tt_register(&tt_removecurse);

View File

@ -881,13 +881,13 @@ resolve_building(void * id) {
}
void
building_write(const struct building * b, FILE * F)
write_building_reference(const struct building * b, FILE * F)
{
fprintf(F, "%s ", b?itoa36(b->no):"0");
}
int
building_read(struct building ** b, FILE * F)
read_building_reference(struct building ** b, FILE * F)
{
int id;
char zText[10];

View File

@ -135,8 +135,8 @@ extern const struct building_type * oldbuildings[MAXBUILDINGTYPES];
#define NOBUILDING NULL
extern void * resolve_building(void * data);
extern void building_write(const struct building * b, FILE * F);
extern int building_read(struct building ** b, FILE * F);
extern void write_building_reference(const struct building * b, FILE * F);
extern int read_building_reference(struct building ** b, FILE * F);
extern struct building *findbuilding(int n);

View File

@ -320,13 +320,13 @@ void
a_writesiege(const attrib * a, FILE * f)
{
struct building * b = (struct building*)a->data.v;
building_write(b, f);
write_building_reference(b, f);
}
int
a_readsiege(attrib * a, FILE * f)
{
return building_read((struct building**)&a->data.v, f);
return read_building_reference((struct building**)&a->data.v, f);
}
attrib_type at_siege = {

View File

@ -8,17 +8,20 @@
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"
/* misc includes */
#include <items/demonseye.h>
#include <attributes/key.h>
#include <triggers/gate.h>
/* kernel includes */
#include <building.h>
#include <faction.h>
#include <item.h>
#include <plane.h>
@ -27,9 +30,10 @@
#include <unit.h>
/* util includes */
#include <base36.h>
#include <umlaut.h>
#include <attrib.h>
#include <base36.h>
#include <event.h>
#include <umlaut.h>
/* libc includes */
#include <stdlib.h>
@ -122,6 +126,34 @@ gm_create(const char * str, void * data, const char * cmd)
}
}
/**
** GM: GATE <id> <x> <y>
** requires: permission-key "gmgate"
**/
static void
gm_gate(const char * str, void * data, const char * cmd)
{
unit * u = (unit*)data;
const struct plane * p = rplane(u->region);
int id = atoi36(igetstrtoken(str));
int x = rel_to_abs(p, u->faction, atoi(getstrtoken()), 0);
int y = rel_to_abs(p, u->faction, atoi(getstrtoken()), 1);
region * r = findregion(x, y);
building * b = findbuilding(id);
if (b==NULL || r==NULL || p!=rplane(b->region) || p!=rplane(r)) {
mistake(u, cmd, "Dieses Gebäude kann die Einheit nicht umwandeln.\n", 0);
return;
} else {
/* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !find_key((attrib*)permissions->data.v, atoi36("gmgate"))) return;
else {
add_trigger(&u->attribs, "timer", trigger_gate(b, r));
}
}
}
/**
** GM: TERRAFORM <terrain> <x> <y>
** requires: permission-key "gmterf"
@ -137,7 +169,7 @@ gm_terraform(const char * str, void * data, const char * cmd)
region * r = findregion(x, y);
terrain_t t;
if (r==NULL || p!=rplane(r)) {
mistake(u, cmd, "Diese Regon kann die Einheit nicht umwandeln.\n", 0);
mistake(u, cmd, "Diese Region kann die Einheit nicht umwandeln.\n", 0);
return;
} else {
/* checking permissions */
@ -300,6 +332,7 @@ init_gmcmd(void)
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, "gate", &gm_gate);
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);
@ -403,6 +436,7 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
a = a_add(&f->attribs, a_new(&at_permissions));
a_add((attrib**)&a->data.v, make_key(atoi36("gmterf")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmgate")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmtele")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmgive")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmskil")));

View File

@ -0,0 +1,99 @@
#include <config.h>
#include <eressea.h>
#include "gate.h"
/* kernel includes */
#include <building.h>
#include <region.h>
#include <unit.h>
/* util includes */
#include <event.h>
#include <log.h>
/* libc includes */
#include <stdlib.h>
typedef struct gate_data {
struct building * gate;
struct region * target;
} gate_data;
static int
gate_handle(trigger * t, void * data)
{
/* call an event handler on gate.
* data.v -> ( variant event, int timer )
*/
gate_data * gd = (gate_data*)t->data.v;
struct building * b = gd->gate;
struct region * r = gd->target;
if (b && r) {
unit ** up = &b->region->units;
while (*up) {
unit * u = *up;
if (u->building==b) move_unit(u, r, NULL);
if (*up==u) up = &u->next;
}
} else {
log_error(("could not perform gate::handle()\n"));
return -1;
}
unused(data);
return 0;
}
static void
gate_write(const trigger * t, FILE * F)
{
gate_data * gd = (gate_data*)t->data.v;
building * b = gd->gate;
region * r = gd->target;
write_building_reference(b, F);
write_region_reference(r, F);
}
static int
gate_read(trigger * t, FILE * F)
{
gate_data * gd = (gate_data*)t->data.v;
read_building_reference(&gd->gate, F);
read_region_reference(&gd->target, F);
return 1;
}
static void
gate_init(trigger * t)
{
t->data.v = calloc(sizeof(gate_data), 1);
}
static void
gate_done(trigger * t)
{
free(t->data.v);
}
struct trigger_type tt_gate = {
"gate",
gate_init,
gate_done,
gate_handle,
gate_write,
gate_read
};
trigger *
trigger_gate(building * b, region * target)
{
trigger * t = t_new(&tt_gate);
gate_data * td = (gate_data*)t->data.v;
td->gate = b;
td->target = target;
return t;
}

View File

@ -0,0 +1,26 @@
/* 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 GATE_H
#define GATE_H
/* all types we use are defined here to reduce dependencies */
struct trigger_type;
struct trigger;
struct region;
struct building;
extern struct trigger_type tt_gate;
extern struct trigger * trigger_gate(struct building * b, struct region * r);
#endif

View File

@ -29,6 +29,7 @@
#include <triggers/changerace.h>
#include <triggers/createcurse.h>
#include <triggers/createunit.h>
#include <triggers/gate.h>
#include <triggers/giveitem.h>
#include <triggers/killunit.h>
#include <triggers/removecurse.h>
@ -50,6 +51,7 @@ init_triggers(void)
tt_register(&tt_changerace);
tt_register(&tt_createcurse);
tt_register(&tt_createunit);
tt_register(&tt_gate);
tt_register(&tt_giveitem);
tt_register(&tt_killunit);
tt_register(&tt_removecurse);

View File

@ -21,6 +21,8 @@
#include <config.h>
#include <eressea.h>
/* misc includes */
#include <attributes/key.h>
#include <modules/xmas2000.h>
#include <modules/museum.h>
@ -1322,18 +1324,15 @@ extern attrib * make_atpermissions(void);
extern struct attrib_type at_permissions;
static void
make_gms(void)
update_gms(void)
{
faction * f = findfaction(atoi36("rr"));
if (f) {
faction * f;
for (f=factions;f;f=f->next) {
attrib * a = a_find(f->attribs, &at_permissions);
if (!a) {
item_type * itype;
a = a_add(&f->attribs, make_atpermissions());
for (itype=itemtypes;itype;itype=itype->next) {
a_add((attrib**)&a->data.v, make_atgmcreate(itype));
if (a) {
if (!find_key((attrib*)a->data.v, atoi36("gmgate"))) {
a_add((attrib**)&a->data.v, make_key(atoi36("gmgate")));
}
a_add((attrib**)&a->data.v, make_key(atoi36("gmtf")));
}
}
}
@ -2245,8 +2244,7 @@ korrektur(void)
#ifdef TEST_GM_COMMANDS
setup_gm_faction();
#endif
make_gms();
/* Wieder entfernen! */
update_gms();
verify_owners(false);
/* fix_herbtypes(); */
#ifdef CONVERT_TRIGGER

View File

@ -29,6 +29,7 @@
#include <triggers/changerace.h>
#include <triggers/createcurse.h>
#include <triggers/createunit.h>
#include <triggers/gate.h>
#include <triggers/giveitem.h>
#include <triggers/killunit.h>
#include <triggers/removecurse.h>
@ -50,6 +51,7 @@ init_triggers(void)
tt_register(&tt_changerace);
tt_register(&tt_createcurse);
tt_register(&tt_createunit);
tt_register(&tt_gate);
tt_register(&tt_giveitem);
tt_register(&tt_killunit);
tt_register(&tt_removecurse);

View File

@ -8,5 +8,4 @@
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
*/

View File

@ -146,7 +146,7 @@ void
warnung(WINDOW * win, const char *text)
{
if (!win) {
win = openwin(strlen(text) + 4, 3, "< WARNUNG >");
win = openwin(strlen(text) + 4, 3, "< WARNING >");
wmove(win, 1, 2);
}
wprintw(win, (NCURSES_CONST char*)"%s", text);
@ -185,7 +185,8 @@ my_input(WINDOW * win, int x, int y, const char *text, const char *def)
if (!win) {
win = openwin(SX - 10, 3, 0);
y = nw = 1;
nw = 1;
y = 1;
x = 2;
}
@ -230,8 +231,10 @@ my_input(WINDOW * win, int x, int y, const char *text, const char *def)
beep();
wrefresh(win);
} while (!(ch == '\n'));
if (nw)
if (nw) {
wclear(win);
delwin(win);
}
curs_set(0);
lbuf[val] = 0;
return lbuf;
@ -367,3 +370,21 @@ do_selection(selection * sel, const char * title, void (*perform)(selection *, v
}
}
}
FILE *
mapperFopen(const char *defName, const char *mode)
{
char nameBuf[80];
FILE *fileP;
strncpy(nameBuf, my_input(0,0,0,"Ausgabe in File: ", defName), 79);
nameBuf[79] = 0;
fileP = fopen(nameBuf, mode);
if(!fileP) {
warnung(NULL, "Can't open file for writing");
}
return fileP;
}

View File

@ -17,6 +17,7 @@
#define BOOL_DEFINED
/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */
#include <config.h>
#include <stdio.h>
#include <curses.h>
#include <eressea.h>
#include "mapper.h"
@ -764,6 +765,25 @@ movearound(int rx, int ry) {
}
ch=-9;
} break;
case 'W':
if(Tagged) {
FILE *mapFile = mapperFopen("mapper.map","w");
const char *tname;
if(mapFile) {
tag=Tagged;
while(tag) {
fprintf(mapFile, "REGION %d %d\n",tag->r->x, tag->r->y);
if(r_isforest(tag->r)) {
tname = "forest";
} else {
tname = terrain[rterrain(tag->r)].name;
}
fprintf(mapFile, "\"%s\"; Terrain\n", locale_string(NULL, tname));
tag=tag->next;
}
fclose(mapFile);
}
} break;
case 'G':
rx=tx; ry=ty;
recalc_everything(&x, &y, &rx, &ry);

View File

@ -61,6 +61,7 @@ void make_new_region(int x, int y);
int map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre);
boolean yes_no(WINDOW * win, const char *text, const char def);
void warnung(WINDOW * win, const char *text);
FILE *mapperFopen(const char *defName, const char *mode);
void adddbllist(dbllist ** S, const char *s);
void ScrollRegList(int dir);
void DisplayRegList(int neu);