DefineNewRaceNames function

Bug #1435722 reported by Andre Novellino Gouvêa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stratagus
Won't Fix
Undecided
Unassigned

Bug Description

I have made a "DefineNewRaceNames" function - it works just like "DefineRaceNames", but without wiping out the already-defined races. Useful for modding support.

/**
** Define new race names
**
** @param l Lua state.
*/
static int CclDefineNewRaceNames(lua_State *l)
{
 int args = lua_gettop(l);
 for (int j = 0; j < args; ++j) {
  const char *value = LuaToString(l, j + 1);
  if (!strcmp(value, "race")) {
   ++j;
   if (!lua_istable(l, j + 1)) {
    LuaError(l, "incorrect argument");
   }
   int subargs = lua_rawlen(l, j + 1);
   int i = PlayerRaces.Count++;
   for (int k = 0; k < subargs; ++k) {
    value = LuaToString(l, j + 1, k + 1);
    if (!strcmp(value, "name")) {
     ++k;
     PlayerRaces.Name[i] = LuaToString(l, j + 1, k + 1);
    } else if (!strcmp(value, "display")) {
     ++k;
     PlayerRaces.Display[i] = LuaToString(l, j + 1, k + 1);
    } else if (!strcmp(value, "visible")) {
     PlayerRaces.Visible[i] = 1;
    } else {
     LuaError(l, "Unsupported tag: %s" _C_ value);
    }
   }
  } else {
   LuaError(l, "Unsupported tag: %s" _C_ value);
  }
 }

 return 0;
}

Revision history for this message
timfelgentreff (timfelgentreff) wrote : Moving to GitHub

This project was moved to https://github.com/Wargus/stratagus. All issues were migrated there.

Changed in stratagus:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.