forked from github/server
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
aae1095c00
13
src/chaos.c
13
src/chaos.c
|
@ -53,6 +53,19 @@ attrib_type at_chaoscount = {
|
|||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
void set_chaoscount(struct region *r, int deaths)
|
||||
{
|
||||
if (deaths==0) {
|
||||
a_removeall(&r->attribs, &at_chaoscount);
|
||||
} else {
|
||||
attrib *a = a_find(r->attribs, &at_chaoscount);
|
||||
if (!a) {
|
||||
a = a_add(&r->attribs, a_new(&at_chaoscount));
|
||||
}
|
||||
a->data.i = deaths;
|
||||
}
|
||||
}
|
||||
|
||||
int get_chaoscount(const region * r)
|
||||
{
|
||||
attrib *a = a_find(r->attribs, &at_chaoscount);
|
||||
|
|
|
@ -29,6 +29,7 @@ extern "C" {
|
|||
void chaos_register(void);
|
||||
void chaos_update(void);
|
||||
|
||||
void set_chaoscount(struct region *r, int deaths);
|
||||
int get_chaoscount(const struct region * r);
|
||||
void add_chaoscount(struct region * r, int deaths);
|
||||
|
||||
|
|
48
src/gmtool.c
48
src/gmtool.c
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "gmtool.h"
|
||||
#include "gmtool_structs.h"
|
||||
#include "chaos.h"
|
||||
#include "console.h"
|
||||
#include "listbox.h"
|
||||
#include "wormhole.h"
|
||||
|
@ -45,6 +46,7 @@
|
|||
#include <attributes/attributes.h>
|
||||
#include <triggers/triggers.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/log.h>
|
||||
#include <util/unicode.h>
|
||||
#include <util/lists.h>
|
||||
|
@ -515,6 +517,46 @@ static void statusline(WINDOW * win, const char *str)
|
|||
wnoutrefresh(win);
|
||||
}
|
||||
|
||||
static void reset_region(region *r) {
|
||||
set_chaoscount(r, 0);
|
||||
r->flags = 0;
|
||||
a_removeall(&r->attribs, NULL);
|
||||
while (r->units) {
|
||||
remove_unit(&r->units, r->units);
|
||||
}
|
||||
while (r->ships) {
|
||||
remove_ship(&r->ships, r->ships);
|
||||
}
|
||||
while (r->buildings) {
|
||||
remove_building(&r->buildings, r->buildings);
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_cursor(state *st) {
|
||||
int nx = st->cursor.x;
|
||||
int ny = st->cursor.y;
|
||||
region *r;
|
||||
pnormalize(&nx, &ny, st->cursor.pl);
|
||||
if ((r = findregion(nx, ny)) != NULL) {
|
||||
reset_region(r);
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_rect(state *st) {
|
||||
int x, y, bs = 3;
|
||||
for (x=0;x!=bs;++x) {
|
||||
for (y = 0; y != bs; ++y) {
|
||||
region *r;
|
||||
int nx = st->cursor.x + x;
|
||||
int ny = st->cursor.y + y;
|
||||
pnormalize(&nx, &ny, st->cursor.pl);
|
||||
if ((r = findregion(nx, ny)) != NULL) {
|
||||
reset_region(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void terraform_at(coordinate * c, const terrain_type * terrain)
|
||||
{
|
||||
if (terrain != NULL) {
|
||||
|
@ -934,6 +976,12 @@ static void handlekey(state * st, int c)
|
|||
st->wnd_status->update |= 1;
|
||||
st->wnd_map->update |= 1;
|
||||
break;
|
||||
case 'c': /* clear/reset */
|
||||
reset_cursor(st);
|
||||
break;
|
||||
case 'C': /* clear/reset */
|
||||
reset_rect(st);
|
||||
break;
|
||||
case 0x09: /* tab = next selected */
|
||||
if (regions != NULL) {
|
||||
map_region *mr = cursor_region(&st->display, cursor);
|
||||
|
|
|
@ -157,9 +157,13 @@ newfaction *read_newfactions(const char *filename)
|
|||
password[0] = '\0';
|
||||
|
||||
if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus,
|
||||
&subscription, password, &alliance) < 3)
|
||||
&subscription, password, &alliance) < 3) {
|
||||
break;
|
||||
if (email[0] == '\0')
|
||||
}
|
||||
if (email[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
if (email[0] == '\0')
|
||||
break;
|
||||
if (password[0] == '\0') {
|
||||
size_t sz;
|
||||
|
|
Loading…
Reference in New Issue