summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-14 23:30:25 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-14 23:30:25 +0300
commit8ab5a7a975aa87ef21619e960d5ca63f0eef3732 (patch)
tree861ea369a0dd41c95e1f61988b5fdafb85c5a784
parentebf09a72221e05de9cd60e3df806f54e29329f4c (diff)
downloadevol-hercules-8ab5a7a975aa87ef21619e960d5ca63f0eef3732.tar.gz
evol-hercules-8ab5a7a975aa87ef21619e960d5ca63f0eef3732.tar.bz2
evol-hercules-8ab5a7a975aa87ef21619e960d5ca63f0eef3732.tar.xz
evol-hercules-8ab5a7a975aa87ef21619e960d5ca63f0eef3732.zip
char: send correct error code if on char creation class or sex is wrong.
-rw-r--r--src/char/char.c32
-rw-r--r--src/char/char.h2
-rw-r--r--src/char/init.c1
3 files changed, 33 insertions, 2 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 571ef3b..2d3e466 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -44,7 +44,7 @@ void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd)
race = RFIFOW(fd, 31);
if (race < min_char_class || race > max_char_class)
{
- chr->creation_failed(fd, 10);
+ chr->creation_failed(fd, -10);
RFIFOSKIP(fd, 31 + 3);
hookStop();
return;
@@ -52,7 +52,7 @@ void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd)
sex = RFIFOB(fd, 33);
if (sex > 1 && sex != 99)
{
- chr->creation_failed(fd, 11);
+ chr->creation_failed(fd, -11);
RFIFOSKIP(fd, 31 + 3);
hookStop();
return;
@@ -88,3 +88,31 @@ void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd)
RFIFOSKIP(fd, 31);
hookStop();
}
+
+void echar_creation_failed(int *fdPtr, int *result)
+{
+ const int fd = *fdPtr;
+ WFIFOHEAD(fd, 3);
+ WFIFOW(fd, 0) = 0x6e;
+ /* Others I found [Ind] */
+ /* 0x02 = Symbols in Character Names are forbidden */
+ /* 0x03 = You are not eligible to open the Character Slot. */
+ /* 0x0B = This service is only available for premium users. */
+ switch (*result)
+ {
+ case -1: WFIFOB(fd, 2) = 0x00; break; // 'Charname already exists'
+ case -2: WFIFOB(fd, 2) = 0xFF; break; // 'Char creation denied'
+ case -3: WFIFOB(fd, 2) = 0x01; break; // 'You are underaged'
+ case -4: WFIFOB(fd, 2) = 0x03; break; // 'You are not eligible to open the Character Slot.'
+ case -5: WFIFOB(fd, 2) = 0x02; break; // 'Symbols in Character Names are forbidden'
+ case -10: WFIFOB(fd, 2) = 0x50; break; // Wrong class
+ case -11: WFIFOB(fd, 2) = 0x51; break; // Wrong sex
+
+ default:
+ ShowWarning("chr->parse_char: Unknown result received from chr->make_new_char_sql: %d!\n", *result);
+ WFIFOB(fd,2) = 0xFF;
+ break;
+ }
+ WFIFOSET(fd,3);
+ hookStop();
+}
diff --git a/src/char/char.h b/src/char/char.h
index 2ebbdb3..7896a0e 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -8,4 +8,6 @@ void echar_parse_char_login_map_server(int *fd);
void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd);
+void echar_creation_failed(int *fdPtr, int *result);
+
#endif // EVOL_CHAR_CHAR
diff --git a/src/char/init.c b/src/char/init.c
index 8e2d34a..440b81c 100644
--- a/src/char/init.c
+++ b/src/char/init.c
@@ -61,6 +61,7 @@ HPExport void plugin_init (void)
addHookPre("chr->parse_char_login_map_server", echar_parse_char_login_map_server);
addHookPre("chr->parse_char_create_new_char", echar_parse_char_create_new_char);
+ addHookPre("chr->creation_failed", echar_creation_failed);
}
HPExport void server_preinit (void)