Permalink
Browse files

Merge pull request #1844 from 4144/newpackets

Add packets for almost all 2014-2017 clients
  • Loading branch information...
MishimaHaruna committed Sep 21, 2017
2 parents 7cbd356 + ee666f0 commit 46f5d10a555785899c04eda74e21922e92a2fb5b
View
@@ -476,7 +476,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
opt |= OPT_SHOW_EQUIP;
if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
"`base_exp`='%"PRIu64"', `job_exp`='%"PRIu64"', `zeny`='%d',"
"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
"`option`='%u',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d',"
@@ -1072,8 +1072,8 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_INT, &p.base_level, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &p.job_level, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT64, &p.base_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT64, &p.job_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL)
@@ -1181,8 +1181,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &p->base_level, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_INT, &p->job_level, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT64, &p->base_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT64, &p->job_exp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL)
@@ -1909,10 +1909,23 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) {
return 0;
buf = WBUFP(buffer,0);
WBUFL(buf,0) = p->char_id;
WBUFL(buf,4) = min(p->base_exp, INT32_MAX);
#if PACKETVER >= 20170830
WBUFQ(buf,4) = min(p->base_exp, INT64_MAX);
offset += 4;
buf = WBUFP(buffer, offset);
#else
WBUFL(buf,4) = min((uint32)(p->base_exp), INT32_MAX);
#endif
WBUFL(buf,8) = p->zeny;
WBUFL(buf,12) = min(p->job_exp, INT32_MAX);
#if PACKETVER >= 20170830
WBUFQ(buf,12) = min(p->job_exp, INT64_MAX);
offset += 4;
buf = WBUFP(buffer, offset);
#else
WBUFL(buf,12) = min((uint32)(p->job_exp), INT32_MAX);
#endif
WBUFL(buf,16) = p->job_level;
WBUFL(buf,20) = 0; // probably opt1
WBUFL(buf,24) = 0; // probably opt2
View
@@ -593,7 +593,7 @@ struct mmo_charstatus {
int mother;
int child;
unsigned int base_exp,job_exp;
uint64 base_exp, job_exp;
int zeny;
int bank_vault;
View
@@ -359,6 +359,28 @@ unsigned int get_percentage(const unsigned int A, const unsigned int B)
return (unsigned int)floor(result);
}
/// calculates the value of A / B, in percent (rounded down)
uint64 get_percentage64(const uint64 A, const uint64 B)
{
double result;
if( B == 0 )
{
ShowError("get_percentage(): division by zero! (A=%"PRIu64",B=%"PRIu64")\n", A, B);
return ~0U;
}
result = 100 * ((double)A / (double)B);
if( result > UINT_MAX )
{
ShowError("get_percentage(): result percentage too high! (A=%"PRIu64",B=%"PRIu64",result=%g)\n", A, B, result);
return UINT_MAX;
}
return (uint64)floor(result);
}
/**
* Applies a percentual rate modifier.
*
View
@@ -44,6 +44,7 @@ bool exists(const char* filename);
/// calculates the value of A / B, in percent (rounded down)
unsigned int get_percentage(const unsigned int A, const unsigned int B);
uint64 get_percentage64(const uint64 A, const uint64 B);
int64 apply_percentrate64(int64 value, int rate, int maxrate);
int apply_percentrate(int value, int rate, int maxrate);
View
@@ -50,7 +50,7 @@ MAP_OBJ = $(addprefix obj_sql/, $(patsubst %c,%o,$(MAP_C)))
MAP_H = atcommand.h battle.h battleground.h buyingstore.h channel.h chat.h \
chrif.h clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h \
instance.h intif.h irc-bot.h itemdb.h log.h mail.h map.h mapreg.h \
mercenary.h mob.h npc.h packets.h packets_struct.h party.h path.h \
mercenary.h mob.h npc.h packets.h packets_keys.h packets_struct.h party.h path.h \
pc.h pc_groups.h pet.h quest.h rodex.h script.h searchstore.h skill.h \
status.h storage.h trade.h unit.h vending.h
MAP_PH =
View
@@ -3035,12 +3035,12 @@ void clif_updatestatus(struct map_session_data *sd,int type)
break;
case SP_BASEEXP:
WFIFOW(fd,0)=0xb1;
WFIFOL(fd,4)=sd->status.base_exp;
WFIFOL(fd,4)=(uint32)(sd->status.base_exp);
len = packet_len(0xb1);
break;
case SP_JOBEXP:
WFIFOW(fd,0)=0xb1;
WFIFOL(fd,4)=sd->status.job_exp;
WFIFOL(fd,4)=(uint32)(sd->status.job_exp);
len = packet_len(0xb1);
break;
case SP_NEXTBASEEXP:
@@ -19928,9 +19928,10 @@ void packetdb_loaddb(void) {
memset(packet_db,0,sizeof(packet_db));
#define packet(id, size, ...) packetdb_addpacket((id), (size), ##__VA_ARGS__, 0xFFFF)
#define packetKeys(a,b,c) do { clif->cryptKey[0] = (a); clif->cryptKey[1] = (b); clif->cryptKey[2] = (c); } while(0)
#include "packets.h" /* load structure data */
#undef packet
#define packetKeys(a,b,c) do { clif->cryptKey[0] = (a); clif->cryptKey[1] = (b); clif->cryptKey[2] = (c); } while(0)
#include "packets_keys.h"
#undef packetKeys
}
void clif_bc_ready(void) {
Oops, something went wrong.

0 comments on commit 46f5d10

Please sign in to comment.