Skip to content

Commit

Permalink
make spell parameters use stb_ds, not custom dynamic arrays (#1063)
Browse files Browse the repository at this point in the history
* make spellparameter use stb_ds

* signed/unsigned comparison warning
  • Loading branch information
ennorehling authored Apr 3, 2024
1 parent 5202a86 commit 6e94117
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 492 deletions.
11 changes: 6 additions & 5 deletions src/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <storage.h>

#include <stb_ds.h>
#include <tolua.h>
#include <lua.h>

Expand Down Expand Up @@ -126,7 +127,7 @@ produce_resource_lua(region * r, const resource_type * rtype, int norders)
}
}

static void push_param(lua_State * L, char c, spllprm * param)
static void push_param(lua_State * L, char c, spellparameter* param)
{
if (c == 'u')
tolua_pushusertype(L, param->data.u, "unit");
Expand Down Expand Up @@ -189,13 +190,13 @@ static int lua_callspell(castorder * co, const char *fname)
tolua_pushusertype(L, caster, "unit");
lua_pushinteger(L, co->level);
lua_pushnumber(L, co->force);
if (co->sp->parameter && co->par->length) {
if (co->sp->parameter && co->a_params) {
const char *synp = co->sp->parameter;
int i = 0;
size_t i = 0, len = arrlen(co->a_params);
++nparam;
lua_newtable(L);
while (*synp && i < co->par->length) {
spllprm *param = co->par->param[i];
while (*synp && i < len) {
spellparameter *param = co->a_params + i;
char c = *synp;
if (c == '+') {
push_param(L, *(synp - 1), param);
Expand Down
Loading

0 comments on commit 6e94117

Please sign in to comment.