Skip to content

Commit

Permalink
remove deprecated init_order_depr
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Aug 16, 2020
1 parent 2e44e2d commit d4400bb
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3750,7 +3750,7 @@ static bool start_battle(region * r, battle ** bp)

/* Ende Fehlerbehandlung Angreifer */

init_order_depr(ord);
init_order(ord, NULL);
/* attackierte Einheit ermitteln */
getunit(r, u->faction, &u2);

Expand Down
2 changes: 1 addition & 1 deletion src/bind_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static int tolua_order_get_token(lua_State *L) {
order *ord = (order *)tolua_tousertype(L, 1, 0);
int n = (int)tolua_tonumber(L, 2, 0);
const char * str = 0;
init_order_depr(ord);
init_order(ord, NULL);
while (n-->0) {
str = getstrtoken();
if (!str) {
Expand Down
18 changes: 9 additions & 9 deletions src/economy.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int give_control_cmd(unit * u, order * ord)
unit *u2;
const char *s;

init_order_depr(ord);
init_order(ord, NULL);
getunit(r, u->faction, &u2);

s = gettoken(token, sizeof(token));
Expand Down Expand Up @@ -921,7 +921,7 @@ int make_cmd(unit * u, struct order *ord)
const struct locale *lang = u->faction->locale;
keyword_t kwd;

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_MAKE);
s = gettoken(token, sizeof(token));

Expand Down Expand Up @@ -1228,7 +1228,7 @@ static void buy(unit * u, econ_request ** buyorders, struct order *ord)
/* Im Augenblick kann man nur 1 Produkt kaufen. expandbuying ist aber
* schon dafuer ausgeruestet, mehrere Produkte zu kaufen. */

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_BUY);
n = getint();
if (n <= 0) {
Expand Down Expand Up @@ -1525,7 +1525,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
/* sellorders sind KEIN array, weil fuer alle items DIE SELBE resource
* (das geld der region) aufgebraucht wird. */

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_SELL);
s = gettoken(token, sizeof(token));

Expand Down Expand Up @@ -1811,7 +1811,7 @@ static void breed_cmd(unit * u, struct order *ord)
}

/* zuechte [<anzahl>] <parameter> */
(void)init_order_depr(ord);
(void)init_order(ord, NULL);
s = gettoken(token, sizeof(token));

m = s ? atoip(s) : 0;
Expand Down Expand Up @@ -1878,7 +1878,7 @@ static void research_cmd(unit * u, struct order *ord)
region *r = u->region;
keyword_t kwd;

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_RESEARCH);

if (effskill(u, SK_HERBALISM, NULL) < 7) {
Expand Down Expand Up @@ -1944,7 +1944,7 @@ static int entertain_cmd(unit * u, struct order *ord, econ_request **io_req)
static int entertainperlevel = 0;
keyword_t kwd;

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_ENTERTAIN);
if (!entertainbase) {
const char *str = config_get("entertain.base");
Expand Down Expand Up @@ -2149,7 +2149,7 @@ void tax_cmd(unit * u, struct order *ord, econ_request ** taxorders)
taxperlevel = config_get_int("taxing.perlevel", 0);
}

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_TAX);

if (!humanoidrace(u_race(u)) && !is_monsters(u->faction)) {
Expand Down Expand Up @@ -2217,7 +2217,7 @@ void loot_cmd(unit * u, struct order *ord, econ_request ** lootorders)
econ_request *o;
keyword_t kwd;

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_LOOT);

if (config_get_int("rules.enable_loot", 0) == 0 && !is_monsters(u->faction)) {
Expand Down
2 changes: 1 addition & 1 deletion src/give.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ void give_cmd(unit * u, order * ord)
message *msg;
keyword_t kwd;

kwd = init_order_depr(ord);
kwd = init_order(ord, NULL);
assert(kwd == K_GIVE);
err = getunit(r, u->faction, &u2);
s = gettoken(token, sizeof(token));
Expand Down
10 changes: 5 additions & 5 deletions src/kernel/alliance.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static void perform_kick(void)

if (al && alliance_get_leader(al) == ta->u->faction) {
faction *f;
init_order_depr(ta->ord);
init_order(ta->ord, NULL);
skip_token();
f = getfaction();
if (f && f_get_alliance(f) == al) {
Expand All @@ -185,7 +185,7 @@ static void perform_new(void)
int id;
faction *f = ta->u->faction;

init_order_depr(ta->ord);
init_order(ta->ord, NULL);
skip_token();
id = getid();

Expand Down Expand Up @@ -220,7 +220,7 @@ static void perform_transfer(void)

if (al && alliance_get_leader(al) == ta->u->faction) {
faction *f;
init_order_depr(ta->ord);
init_order(ta->ord, NULL);
skip_token();
f = getfaction();
if (f && f_get_alliance(f) == al) {
Expand Down Expand Up @@ -257,7 +257,7 @@ static void perform_join(void)
faction *fj = ta->u->faction;
int aid;

init_order_depr(ta->ord);
init_order(ta->ord, NULL);
skip_token();
aid = getid();
if (aid) {
Expand All @@ -269,7 +269,7 @@ static void perform_join(void)
faction *fi = ti->u->faction;
if (fi && f_get_alliance(fi) == al) {
int fid;
init_order_depr(ti->ord);
init_order(ti->ord, NULL);
skip_token();
fid = getid();
if (fid == fj->no) {
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int destroy_cmd(unit * u, struct order *ord)
return 52;
}

init_order_depr(ord);
init_order(ord, NULL);
s = gettoken(token, sizeof(token));

if (s && *s) {
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int do_command_i(const struct tnode *keys, struct unit *u, struct order *

void do_command(const struct tnode *keys, struct unit *u, struct order *ord)
{
init_order_depr(ord);
init_order(ord, NULL);
if (do_command_i(keys, u, ord) != E_TOK_SUCCESS) {
char cmd[ORDERSIZE];
get_command(ord, u->faction->locale, cmd, sizeof(cmd));
Expand Down
24 changes: 12 additions & 12 deletions src/kernel/config.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ static void test_read_unitid(CuTest *tc) {
usetalias(u, atoi36("42"));

ord = create_order(K_GIVE, lang, "TEMP 42");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, u->no, read_unitid(u->faction, u->region));
free_order(ord);

ord = create_order(K_GIVE, lang, "8");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, 8, read_unitid(u->faction, u->region));
free_order(ord);

ord = create_order(K_GIVE, lang, "");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region));
free_order(ord);

ord = create_order(K_GIVE, lang, "TEMP");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region));
free_order(ord);

/* bug https://bugs.eressea.de/view.php?id=1685 */
ord = create_order(K_GIVE, lang, "##");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region));
free_order(ord);

Expand All @@ -79,42 +79,42 @@ static void test_getunit(CuTest *tc) {
r = test_create_region(1, 0, t_plain);

ord = create_order(K_GIVE, lang, itoa36(u->no));
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_UNIT, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, u, u2);
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_NOTFOUND, getunit(r, u->faction, &u2));
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);

ord = create_order(K_GIVE, lang, itoa36(u->no + 1));
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);

ord = create_order(K_GIVE, lang, "0");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_PEASANTS, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);

/* bug https://bugs.eressea.de/view.php?id=1685 */
ord = create_order(K_GIVE, lang, "TEMP ##");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);

/* bug https://bugs.eressea.de/view.php?id=1685 */
ord = create_order(K_GIVE, lang, "##");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);

ord = create_order(K_GIVE, lang, "TEMP 42");
init_order_depr(ord);
init_order(ord, NULL);
CuAssertIntEquals(tc, GET_UNIT, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, u, u2);
free_order(ord);
Expand Down
10 changes: 3 additions & 7 deletions src/kernel/order.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,13 @@ keyword_t init_order(const struct order *ord, const struct locale *lang)
}
}

keyword_t init_order_depr(const struct order *ord)
void reset_order(void)
{
if (ord) {
keyword_t kwd = ORD_KEYWORD(ord);
assert(kwd != K_STUDY && kwd != K_AUTOSTUDY && kwd != K_FORGET);
}
return init_order(ord, NULL);
(void)init_order(NULL, NULL);
}

void close_orders(void) {
if (parser_od) {
(void)init_order(NULL, NULL);
reset_order();
}
}
2 changes: 1 addition & 1 deletion src/kernel/order.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ extern "C" {
char *write_order(const order * ord, const struct locale *lang,
char *buffer, size_t size);
int stream_order(struct stream *out, const struct order *ord, const struct locale *lang, bool escape);
keyword_t init_order_depr(const struct order *ord);
keyword_t init_order(const struct order *ord, const struct locale *lang);
void reset_order(void);

void close_orders(void);

Expand Down
6 changes: 3 additions & 3 deletions src/kernel/order.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void test_create_order(CuTest *tc) {
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
CuAssertStrEquals(tc, "move NORTH", get_command(ord, lang, cmd, sizeof(cmd)));

CuAssertIntEquals(tc, K_MOVE, init_order_depr(ord));
CuAssertIntEquals(tc, K_MOVE, init_order(ord, NULL));
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);
test_teardown();
Expand All @@ -50,7 +50,7 @@ static void test_parse_order(CuTest *tc) {
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
CuAssertStrEquals(tc, "move NORTH", get_command(ord, lang, cmd, sizeof(cmd)));

CuAssertIntEquals(tc, K_MOVE, init_order_depr(ord));
CuAssertIntEquals(tc, K_MOVE, init_order(ord, NULL));
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);

Expand Down Expand Up @@ -109,7 +109,7 @@ static void test_parse_make(CuTest *tc) {
CuAssertIntEquals(tc, K_MAKE, getkeyword(ord));
CuAssertStrEquals(tc, "MAKE hurrdurr", get_command(ord, lang, cmd, sizeof(cmd)));

CuAssertIntEquals(tc, K_MAKE, init_order_depr(ord));
CuAssertIntEquals(tc, K_MAKE, init_order(ord, NULL));
CuAssertStrEquals(tc, "hurrdurr", getstrtoken());
free_order(ord);
test_teardown();
Expand Down
Loading

0 comments on commit d4400bb

Please sign in to comment.