Project

General

Profile

Feature #1451 » lua-specialist-nullptr.patch

Alexandr Ignatiev, 05/27/2025 11:40 PM

View differences:

common/scriptcore/api_game_find.c
return achievement_by_rule_name(name_orig);
}
/**********************************************************************//**
Return the specialist with the given name_orig.
**************************************************************************/
Specialist *api_find_specialist_by_name(lua_State *L, const char *name_orig)
{
LUASCRIPT_CHECK_STATE(L, nullptr);
LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
return specialist_by_rule_name(name_orig);
}
/**********************************************************************//**
Return the specialist with the given spec_id index.
**************************************************************************/
Specialist *api_find_specialist(lua_State *L, int spec_id)
{
LUASCRIPT_CHECK_STATE(L, nullptr);
return specialist_by_number((Specialist_type_id) spec_id);
}
/**********************************************************************//**
Return the disaster with the given disaster_id index.
**************************************************************************/
common/scriptcore/api_game_find.h
Achievement *api_find_achievement(lua_State *L, int achievement_id);
Achievement *api_find_achievement_by_name(lua_State *L, const char *name_orig);
Specialist *api_find_specialist_by_name(lua_State *L, const char *name_orig);
Specialist *api_find_specialist(lua_State *L, int spec_id);
Disaster *api_find_disaster(lua_State *L, int disaster_id);
Disaster *api_find_disaster_by_name(lua_State *L, const char *name_orig);
common/scriptcore/api_game_methods.c
return action_target_kind_name(action_get_target_kind(paction));
}
/**********************************************************************//**
Return specialist rule name
**************************************************************************/
const char *api_methods_specialist_rule_name(lua_State *L, Specialist *s)
{
LUASCRIPT_CHECK_STATE(L, nullptr);
LUASCRIPT_CHECK_SELF(L, s, nullptr);
return specialist_rule_name(s);
}
/**********************************************************************//**
Return translated name for specialist
**************************************************************************/
const char *api_methods_specialist_name_translation(lua_State *L,
Specialist *s)
{
LUASCRIPT_CHECK_STATE(L, nullptr);
LUASCRIPT_CHECK_SELF(L, s, nullptr);
return specialist_plural_translation(s);
}
/**********************************************************************//**
Return the native x coordinate of the tile.
**************************************************************************/
common/scriptcore/api_game_methods.h
Action *pact);
const char *api_methods_action_target_kind(lua_State *L, Action *pact);
/* Specialist */
const char *api_methods_specialist_rule_name(lua_State *L, Specialist *s);
const char *api_methods_specialist_name_translation(lua_State *L,
Specialist *s);
/* Tile */
int api_methods_tile_nat_x(lua_State *L, Tile *ptile);
int api_methods_tile_nat_y(lua_State *L, Tile *ptile);
common/scriptcore/luascript_types.h
#include "improvement.h"
#include "nation.h"
#include "player.h"
#include "specialist.h"
#include "tech.h"
#include "terrain.h"
#include "tile.h"
......
typedef struct disaster_type Disaster;
typedef struct achievement Achievement;
typedef struct action Action;
typedef struct specialist Specialist;
typedef struct packet_game_info Game_Info;
typedef void Nonexistent;
......
#define SPECENUM_VALUE16NAME "Achievement"
#define SPECENUM_VALUE17 API_TYPE_ACTION
#define SPECENUM_VALUE17NAME "Action"
#define SPECENUM_VALUE18 API_TYPE_SPECIALIST
#define SPECENUM_VALUE18NAME "Specialist"
#include "specenum_gen.h"
#ifdef __cplusplus
common/scriptcore/tolua_common_z.pkg
"Disaster",
"Achievement",
"Action",
"Specialist",
"Direction",
"Game_Info"
}
common/scriptcore/tolua_game.pkg
const int id;
};
struct Specialist {
const int item_number @ id;
};
struct Direction {
/* nothing here, it's enum */
};
......
@ target_kind (lua_State *L, Action *self);
}
/* Module Specialist */
module Specialist {
const char *api_methods_specialist_rule_name
@ rule_name (lua_State *L, Specialist *self);
const char *api_methods_specialist_name_translation
@ name_translation (lua_State *L, Specialist *self);
}
/* Module Unit_List_Link. */
module Unit_List_Link {
Unit *api_methods_unit_list_link_data
......
@ achievement (lua_State *L, const char *name_orig);
Achievement *api_find_achievement
@ achievement (lua_State *L, int achievement_id);
Specialist *api_find_specialist_by_name
@ specialist (lua_State *L, const char *name_orig);
Specialist *api_find_specialist
@ specialist (lua_State *L, int spec_id);
Disaster *api_find_disaster_by_name
@ disaster (lua_State *L, const char *name_orig);
Disaster *api_find_disaster
(2-2/2)