Jump to content
  • 0

Error with Atcommand Events diff


sizenine

Question


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

I'm getting this error:

npc.c:784: undefined reference to `aMallocA'

from applying this diff by ToastOfDoom.. can anyone help me solve this?

http://www.eathena.w...howtopic=272578

Here is part of the src that shows line 784 in npc.c:

+int do_atcmd_event (struct map_session_data* sd, const char* command, const char* message, const char* eventname)
+{
+ struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname);
+ struct npc_data *nd;
+ struct script_state *st;
+ int i = 0, j = 0, k = 0;
+ char *temp;
+ temp = (char*)aMallocA(strlen(message) + 1);

+
+ nullpo_ret(sd);
+
+ if( ev == NULL || (nd = ev->nd) == NULL )
+ {
+ ShowError("npc_event: event not found [%s]n", eventname);
+ return 0;

Edited by sizenine
Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  530
  • Reputation:   33
  • Joined:  01/17/12
  • Last Seen:  

replace aMallocA with aMalloc

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

Thanks that seems to have worked but now I found a possible glitch...

I've written somewhat of a small script to add a requirement for Emperium when using the command @guild:


- script atcmd_sample_inject -1,{

OnInit:
bindatcmd("guild", "atcmd_sample_inject::OnAtCmd");
end;



OnAtCmd:
if (.@atcmd_command$ == "$guild") { end; }
if(countitem(714) < 1) 
{
dispbottom "You need the necessary item to create a Guild.";
}
else
{
useatcmd "@guild " + .@atcmd_parameters$[0];
}
end;

}

After implementing that script, the @guild command works fine with the item requirement. However, when I try to use #guild <charname> <guildname>, the map server will receive a crash signal. Is there something wrong with my script? Or is this a flaw in the diff?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  43
  • Reputation:   2
  • Joined:  01/17/12
  • Last Seen:  

Probably has something to do with attached player when checking and "useatcmd"-ing, probably null reference in useatcmd. Put some console debug writers in that function and see what you get.

My guess is that it doesn't check whether <charname> is actually a character.

Edited by Derceto
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

Probably has something to do with attached player when checking and "useatcmd"-ing, probably null reference in useatcmd. Put some console debug writers in that function and see what you get.

My guess is that it doesn't check whether <charname> is actually a character.

Sorry I'm not too familiar with console debug writers".. but I've tried it on actual existing char names and it still crashes the server.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  43
  • Reputation:   2
  • Joined:  01/17/12
  • Last Seen:  

I mean, find the function "useatcmd" and fill it with ShowInfo() watches to see what happens when it crashes

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

so i just stick a bunch of "ShowInfo()" between the code lines?

BUILDIN_FUNC(useatcmd)
{
TBL_PC dummy_sd;
ShowInfo();
TBL_PC* sd;
ShowInfo();
int fd;
ShowInfo();
const char* cmd;
ShowInfo();
cmd = script_getstr(st,2);

if (st->rid) {
ShowInfo();
sd = script_rid2sd(st);
ShowInfo();
fd = sd->fd;
ShowInfo();
} else { //Use a dummy character.
ShowInfo();
sd = &dummy_sd;
fd = 0;
ShowInfo();
memset(&dummy_sd, 0, sizeof(TBL_PC));
ShowInfo();
if (st->oid)
{
ShowInfo();
struct block_list* bl = map_id2bl(st->oid);
ShowInfo();
memcpy(&dummy_sd.bl, bl, sizeof(struct block_list));
ShowInfo();
if (bl->type == BL_NPC)
ShowInfo();
safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
ShowInfo();
}
ShowInfo();
}

// compatibility with previous implementation (deprecated!)
if(cmd[0] != atcommand_symbol)
{
ShowInfo();
cmd += strlen(sd->status.name);
ShowInfo();
while(*cmd != atcommand_symbol && *cmd != 0)
ShowInfo();
cmd++;
}
ShowInfo();
is_atcommand(fd, sd, cmd, 2);
ShowInfo();
return 0;
}

lol... like that? i dont know what im doing obviously.

Edited by sizenine
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  43
  • Reputation:   2
  • Joined:  01/17/12
  • Last Seen:  

showinfo() is an extension (remake) of printf().

syntax: showinfo(formatString, ...)

Normally you would write

ShowInfo("useatcmd: somevariable = %d n", somevariable);

for integers. For floating point you use "%f" instead of "%d", for strings "%s".

But if you're asking it this far, I suppose you won't know what to do after that anyway. Wait for someone less lazy than me come by.

Edited by Derceto
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

oh i see.. i know what printf() is but yeah i probably wouldn't know what the values mean and how to fix it even if i printed out the results..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  87
  • Reputation:   1
  • Joined:  11/20/11
  • Last Seen:  

Hello.. I didn't want to open another thread because, my concern is also about the atcommand events mod.

I get this error when I try to use #command.

19p9gn.png

What I added is just this line

  	 if( .@atcmd_command$ == "#testshop")
  	 { end; }

Here's what's written on npc.c line 782

nullpo_ret(sd);

npc.c

int do_atcmd_event (struct map_session_data* sd, const char* command, const char* message, const char* eventname)
{
struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname);
struct npc_data *nd;
struct script_state *st;
int i = 0, j = 0, k = 0;
char *temp;
temp = (char*)aMalloc(strlen(message) + 1);

nullpo_ret(sd);

if( ev == NULL || (nd = ev->nd) == NULL )
{
	ShowError("npc_event: event not found [%s]\n", eventname);
	return 0;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

Quite hard to understand the issues here, not so familiar with Toasty diff to get an idea.

Anyway gdb would help on the matter, you may have some info here :

http://rathena.org/wiki/GDB

Or all you guys need to do is :

gdb -ex run map-server_sql

Than also run the 2 other part :

./login-server_sql

./char-server_sql

With this will have a better view of what may wrong when crashing. (use "bt full" when this append to have a more consistent report)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...