Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/common/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ static void console_parse_create(char *name, CParseFunc func)
nullpo_retv(name);
safestrncpy(sublist, name, CP_CMD_LENGTH * 5);
tok = strtok(sublist,":");
nullpo_retv(tok);

ARR_FIND(0, VECTOR_LENGTH(console->input->command_list), i, strcmpi(tok, VECTOR_INDEX(console->input->command_list, i)->cmd) == 0);

Expand Down Expand Up @@ -404,6 +405,10 @@ static void console_parse_sub(char *line)
nullpo_retv(line);
memcpy(bline, line, 200);
tok = strtok(line, " ");
if (tok == NULL) {
// Ignore empty commands
return;
}

ARR_FIND(0, VECTOR_LENGTH(console->input->command_list), i, strcmpi(tok, VECTOR_INDEX(console->input->command_list, i)->cmd) == 0);
if (i == VECTOR_LENGTH(console->input->command_list)) {
Expand All @@ -417,6 +422,12 @@ static void console_parse_sub(char *line)

if (cmd->type == CPET_FUNCTION) {
tok = strtok(NULL, "");
if (tok != NULL) {
while (tok[0] == ' ')
tok++;
if (tok[0] == '\0')
tok = NULL;
}
cmd->u.func(tok);
return;
}
Expand Down Expand Up @@ -444,6 +455,12 @@ static void console_parse_sub(char *line)
entry = VECTOR_INDEX(cmd->u.children, i);
if (entry->type == CPET_FUNCTION) {
tok = strtok(NULL, "");
if (tok != NULL) {
while (tok[0] == ' ')
tok++;
if (tok[0] == '\0')
tok = NULL;
}
entry->u.func(tok);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "map/mapreg.h"
#include "map/mercenary.h"
#include "map/mob.h"
#include "map/npc.h"
#include "map/npc.h" // npc_setcells(), npc_unsetcells()
#include "map/party.h"
#include "map/path.h"
Expand Down Expand Up @@ -6305,6 +6304,7 @@ static CPCMD(gm_position)
map->cpsd->bl.x = x;
map->cpsd->bl.y = y;
map->cpsd->bl.m = m;
map->cpsd->mapindex = map_id2index(m);
}
static CPCMD(gm_use)
{
Expand Down Expand Up @@ -6333,6 +6333,8 @@ static void map_cp_defaults(void)
map->cpsd->bl.x = mapindex->default_x;
map->cpsd->bl.y = mapindex->default_y;
map->cpsd->bl.m = map->mapname2mapid(mapindex->default_map);
Assert_retv(map->cpsd->bl.m >= 0);
map->cpsd->mapindex = map_id2index(map->cpsd->bl.m);

console->input->addCommand("gm:info",CPCMD_A(gm_position));
console->input->addCommand("gm:use",CPCMD_A(gm_use));
Expand Down