Skip to content

Instantly share code, notes, and snippets.

@lighta
Created December 30, 2015 18:56
Show Gist options
  • Save lighta/ac5b5a57bbe40d8b079f to your computer and use it in GitHub Desktop.
Save lighta/ac5b5a57bbe40d8b079f to your computer and use it in GitHub Desktop.
chclif_createnewchar_ack
int chclif_createnewchar_ack(int fd, struct char_session_data* sd,int idx){
//'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3)
if (idx < 0) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x6e;
/* Others I found [Ind] */
/* 0x02 = Symbols in Character Names are forbidden */
/* 0x03 = You are not elegible to open the Character Slot. */
switch (idx) {
case -1: WFIFOB(fd,2) = 0x00; break;
case -2: WFIFOB(fd,2) = 0xFF; break;
case -3: WFIFOB(fd,2) = 0x01; break;
case -4: WFIFOB(fd,2) = 0x03; break;
}
WFIFOSET(fd,3);
} else {
int len, ch;
// retrieve data
struct mmo_charstatus char_dat;
char_mmo_char_fromsql(idx, &char_dat, false); //Only the short data is needed.
// send to player
WFIFOHEAD(fd,2+MAX_CHAR_BUF);
WFIFOW(fd,0) = 0x6d;
len = 2 + char_mmo_char_tobuf(WFIFOP(fd,2), &char_dat);
WFIFOSET(fd,len);
// add new entry to the chars list
ARR_FIND( 0, MAX_CHARS, ch, sd->found_char[ch] == -1 );
if( ch < MAX_CHARS )
sd->found_char[ch] = idx; // the char_id of the new char
}
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment