diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 17 | ||||
-rw-r--r-- | src/common/mmo.h | 5 | ||||
-rw-r--r-- | src/map/atcommand.c | 8 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/itemdb.h | 9 | ||||
-rw-r--r-- | src/map/npc.c | 71 | ||||
-rw-r--r-- | src/map/npc.h | 4 | ||||
-rw-r--r-- | src/map/pc.c | 56 | ||||
-rw-r--r-- | src/map/pc.h | 1 | ||||
-rw-r--r-- | src/map/script.c | 6 |
10 files changed, 149 insertions, 38 deletions
diff --git a/src/char/char.c b/src/char/char.c index 240acab53..3cc1547ac 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -463,7 +463,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || - (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) + (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) ) { //Save status unsigned int opt = 0; @@ -479,7 +479,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d'," "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," "`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d'," - "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u'" + "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u'" " WHERE `account_id`='%d' AND `char_id` = '%d'", char_db, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, @@ -490,7 +490,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size - p->robe,p->slotchange,opt, + p->robe,p->slotchange,opt,p->font, p->account_id, p->char_id) ) { Sql_ShowDebug(sql_handle); @@ -1052,7 +1052,7 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL) @@ -1115,7 +1115,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`," "`hair_color`,`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`," "`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`,`slotchange`," - "`char_opt`" + "`char_opt`,`font`" " FROM `%s` WHERE `char_id`=? LIMIT 1", char_db) || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) || SQL_ERROR == SQL->StmtExecute(stmt) @@ -1148,7 +1148,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) @@ -1168,11 +1168,12 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything || SQL_ERROR == SQL->StmtBindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UCHAR, &p->font, 0, NULL, NULL) ) { SqlStmt_ShowDebug(stmt); diff --git a/src/common/mmo.h b/src/common/mmo.h index 13748a787..5f75f35da 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -414,9 +414,8 @@ struct mmo_charstatus { unsigned short slotchange; time_t delete_date; - - /* `account_data` modifiers */ - unsigned short mod_exp,mod_drop,mod_death; + + unsigned char font; }; typedef enum mail_status { diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 7ec589956..146159c63 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8111,9 +8111,9 @@ ACMD(font) { font_id = atoi(message); if( font_id == 0 ) { - if( sd->user_font ) + if( sd->status.font ) { - sd->user_font = 0; + sd->status.font = 0; clif->message(fd, msg_txt(1356)); // Returning to normal font. clif->font(sd); } @@ -8125,9 +8125,9 @@ ACMD(font) { } else if( font_id < 0 || font_id > 9 ) clif->message(fd, msg_txt(1359)); // Invalid font. Use a value from 0 to 9. - else if( font_id != sd->user_font ) + else if( font_id != sd->status.font ) { - sd->user_font = font_id; + sd->status.font = font_id; clif->font(sd); clif->message(fd, msg_txt(1360)); // Font changed. } diff --git a/src/map/clif.c b/src/map/clif.c index a5e92b998..c752f822d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -611,7 +611,7 @@ void clif_authok(struct map_session_data *sd) p.xSize = p.ySize = 5; /* not-used */ #if PACKETVER >= 20080102 - p.font = sd->user_font; // FIXME: Font is currently not saved. + p.font = sd->status.font; #endif clif->send(&p,sizeof(p),&sd->bl,SELF); @@ -982,7 +982,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.state = vd->dead_sit; p.clevel = clif_setlevel(bl); #if PACKETVER >= 20080102 - p.font = (sd) ? sd->user_font : 0; + p.font = (sd) ? sd->status.font : 0; #endif #if PACKETVER >= 20140000 //actual 20120221 if( bl->type == BL_MOB ) { @@ -1110,7 +1110,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.xSize = p.ySize = (sd) ? 5 : 0; p.clevel = clif_setlevel(bl); #if PACKETVER >= 20080102 - p.font = (sd) ? sd->user_font : 0; + p.font = (sd) ? sd->status.font : 0; #endif #if PACKETVER >= 20140000 //actual 20120221 if( bl->type == BL_MOB ) { @@ -1188,7 +1188,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.xSize = p.ySize = (sd) ? 5 : 0; p.clevel = clif_setlevel(bl); #if PACKETVER >= 20080102 - p.font = (sd) ? sd->user_font : 0; + p.font = (sd) ? sd->status.font : 0; #endif #if PACKETVER >= 20140000 //actual 20120221 if( bl->type == BL_MOB ) { @@ -16101,7 +16101,7 @@ void clif_font(struct map_session_data *sd) nullpo_retv(sd); WBUFW(buf,0) = 0x2ef; WBUFL(buf,2) = sd->bl.id; - WBUFW(buf,6) = sd->user_font; + WBUFW(buf,6) = sd->status.font; clif->send(buf, packet_len(0x2ef), &sd->bl, AREA); #endif } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 0f46c1c01..2579d84ca 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -48,6 +48,15 @@ enum item_itemid { ITEMID_TRAP_ALLOY = 7940, ITEMID_ANCILLA = 12333, ITEMID_REINS_OF_MOUNT = 12622, + ITEMID_LOVE_ANGEL = 12287, + ITEMID_SQUIRREL = 12288, + ITEMID_GOGO = 12289, + ITEMID_PICTURE_DIARY = 12304, + ITEMID_MINI_HEART = 12305, + ITEMID_NEWCOMER = 12306, + ITEMID_KID = 12307, + ITEMID_MAGIC_CASTLE = 12308, + ITEMID_BULGING_HEAD = 12309, }; /** diff --git a/src/map/npc.c b/src/map/npc.c index ff95cf82d..f0bdd7bd0 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2013,6 +2013,53 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con } } +// Parse View +// Support for using Constants in place of NPC View IDs. +int npc_parseview(const char* w4, const char* start, const char* buffer, const char* filepath) { + int val = -1, i = 0; + char viewid[1024]; // Max size of name from const.txt, see script->read_constdb. + + // Extract view ID / constant + while (w4[i] != '\0') { + if (isspace(w4[i]) || w4[i] == '/' || w4[i] == ',') + break; + + i++; + } + + safestrncpy(viewid, w4, i+=1); + + // Check if view id is not an ID (only numbers). + if(!npc->viewisid(viewid)) + { + // Check if constant exists and get its value. + if(!script->get_constant(viewid, &val)) { + ShowWarning("npc_parseview: Invalid NPC constant '%s' specified in file '%s', line'%d'. Defaulting to INVISIBLE_CLASS. \n", viewid, filepath, strline(buffer,start-buffer)); + val = INVISIBLE_CLASS; + } + } else { + // NPC has an ID specified for view id. + val = atoi(w4); + } + + return val; +} + +// View is ID +// Checks if given view is an ID or constant. +bool npc_viewisid(const char * viewid) +{ + if(atoi(viewid) != -1) + { + // Loop through view, looking for non-numeric character. + while (*viewid) { + if (isdigit(*viewid++) == 0) return false; + } + } + + return true; +} + //Add then display an npc warp on map struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y) { int i, flag = 0; @@ -2220,7 +2267,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s nd->bl.y = y; nd->bl.id = npc->get_new_npc_id(); npc->parsename(nd, w3, start, buffer, filepath); - nd->class_ = m==-1?-1:atoi(w4); + nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath); nd->speed = 200; ++npc_shop; @@ -2335,7 +2382,7 @@ const char* npc_skip_script(const char* start, const char* buffer, const char* f /// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>} /// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>} const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) { - int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov + int x, y, dir = 0, m, xs = 0, ys = 0; // [Valaris] thanks to fov char mapname[32]; struct script_code *scriptroot; int i; @@ -2383,14 +2430,13 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* CREATE(nd, struct npc_data, 1); - if( sscanf(w4, "%d,%d,%d", &class_, &xs, &ys) == 3 ) + if( sscanf(w4, "%*[^,],%d,%d", &xs, &ys) == 2 ) {// OnTouch area defined nd->u.scr.xs = xs; nd->u.scr.ys = ys; } else {// no OnTouch area - class_ = atoi(w4); nd->u.scr.xs = -1; nd->u.scr.ys = -1; } @@ -2401,7 +2447,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* nd->bl.y = y; npc->parsename(nd, w3, start, buffer, filepath); nd->bl.id = npc->get_new_npc_id(); - nd->class_ = class_; + nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath); nd->speed = 200; nd->u.scr.script = scriptroot; nd->u.scr.label_list = label_list; @@ -2417,7 +2463,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* nd->dir = dir; npc->setcells(nd); map->addblock(&nd->bl); - if( class_ >= 0 ) { + if( nd->class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); @@ -2465,7 +2511,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* /// npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<name of target>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY> const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { - int x, y, dir, m, xs = -1, ys = -1, class_ = 0; + int x, y, dir, m, xs = -1, ys = -1; char mapname[32]; char srcname[128]; int i; @@ -2515,9 +2561,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch } if( type == WARP && sscanf(w4, "%d,%d", &xs, &ys) == 2 );// <spanx>,<spany> - else if( type == SCRIPT && sscanf(w4, "%d,%d,%d", &class_, &xs, &ys) == 3);// <sprite id>,<triggerX>,<triggerY> - else if( type != WARP ) class_ = atoi(w4);// <sprite id> - else { + else if( type == SCRIPT && sscanf(w4, "%*d,%d,%d", &xs, &ys) == 2);// <sprite id>,<triggerX>,<triggerY> + else if( type == WARP ) { ShowError("npc_parse_duplicate: Invalid span format for duplicate warp in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return end;// next line, try to continue } @@ -2530,7 +2575,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch nd->bl.y = y; npc->parsename(nd, w3, start, buffer, filepath); nd->bl.id = npc->get_new_npc_id(); - nd->class_ = class_; + nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath); nd->speed = 200; nd->src_id = src_id; nd->bl.type = BL_NPC; @@ -2573,7 +2618,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch nd->dir = dir; npc->setcells(nd); map->addblock(&nd->bl); - if( class_ >= 0 ) { + if( nd->class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); @@ -4045,6 +4090,8 @@ void npc_defaults(void) { npc->addsrcfile = npc_addsrcfile; npc->delsrcfile = npc_delsrcfile; npc->parsename = npc_parsename; + npc->parseview = npc_parseview; + npc->viewisid = npc_viewisid; npc->add_warp = npc_add_warp; npc->parse_warp = npc_parse_warp; npc->parse_shop = npc_parse_shop; diff --git a/src/map/npc.h b/src/map/npc.h index e1ec6e5e4..5ec201e55 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -92,7 +92,7 @@ enum actor_classes { #define MAX_NPC_CLASS 1000 // New NPC range #define MAX_NPC_CLASS2_START 10000 -#define MAX_NPC_CLASS2_END 10049 +#define MAX_NPC_CLASS2_END 10070 //Checks if a given id is a valid npc id. [Skotlex] //Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001) @@ -197,6 +197,8 @@ struct npc_interface { void (*addsrcfile) (const char *name); void (*delsrcfile) (const char *name); void (*parsename) (struct npc_data *nd, const char *name, const char *start, const char *buffer, const char *filepath); + int (*parseview) (const char *w4, const char *start, const char *buffer, const char *filepath); + bool (*viewisid) (const char *viewid); struct npc_data* (*add_warp) (char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); const char* (*parse_warp) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); const char* (*parse_shop) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); diff --git a/src/map/pc.c b/src/map/pc.c index 564bc42d7..2f4682413 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -446,12 +446,66 @@ int pc_inventory_rental_clear(struct map_session_data *sd) /* assumes i is valid (from default areas where it is called, it is) */ void pc_rental_expire(struct map_session_data *sd, int i) { short nameid = sd->status.inventory[i].nameid; - + /* Soon to be dropped, we got plans to integrate it with item db */ switch( nameid ) { case ITEMID_REINS_OF_MOUNT: status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER); break; + case ITEMID_LOVE_ANGEL: + if( sd->status.font == 1 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_SQUIRREL: + if( sd->status.font == 2 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_GOGO: + if( sd->status.font == 3 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_PICTURE_DIARY: + if( sd->status.font == 4 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_MINI_HEART: + if( sd->status.font == 5 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_NEWCOMER: + if( sd->status.font == 6 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_KID: + if( sd->status.font == 7 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_MAGIC_CASTLE: + if( sd->status.font == 8 ) { + sd->status.font = 0; + clif->font(sd); + } + break; + case ITEMID_BULGING_HEAD: + if( sd->status.font == 9 ) { + sd->status.font = 0; + clif->font(sd); + } + break; } clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); diff --git a/src/map/pc.h b/src/map/pc.h index 5f12052ca..fc37d0ef2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -449,7 +449,6 @@ struct map_session_data { const char* debug_func; unsigned int bg_id; - unsigned short user_font; /** * For the Secure NPC Timeout option (check config/Secure.h) [RR] diff --git a/src/map/script.c b/src/map/script.c index 2a83f3918..d51f27ce9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16229,10 +16229,10 @@ BUILDIN(setfont) if( sd == NULL ) return true; - if( sd->user_font != font ) - sd->user_font = font; + if( sd->status.font != font ) + sd->status.font = font; else - sd->user_font = 0; + sd->status.font = 0; clif->font(sd); return true; |