viewing paste aelys_sprefresh.diff | Diff

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
Index: src/map/script.c
===================================================================
--- src/map/script.c    (revision 409)
+++ src/map/script.c    (working copy)
@@ -7864,6 +7864,7 @@
    int val4 = 0;
    int val5 = 0;
    TBL_PC* sd;
+   int nb_args=0;
 
    sd = script_rid2sd(st);
    if( sd == NULL )
@@ -7895,7 +7896,8 @@
            break;
    }
 
-   switch( script_lastdata(st)-2 ) {
+   nb_args = script_lastdata(st)-2;
+   switch( nb_args ) {
        case 1:
            pc_bonus(sd, type, val1);
            break;
@@ -7933,6 +7935,8 @@
            ShowDebug("buildin_bonus: unexpected number of arguments (%d)\n", (script_lastdata(st) - 1));
            break;
    }
+   if(nb_args <= 5)
+       clif_sp_refresh(sd,type);
 
    return 0;
 }
Index: src/map/clif.c
===================================================================
--- src/map/clif.c  (revision 408)
+++ src/map/clif.c  (working copy)
@@ -54,6 +54,7 @@
 
 /* for clif_clearunit_delayed */
 static struct eri *delay_clearunit_ers;
+static DBMap* clif_sprefresh_db; //refreshable SP hash
 
 //#define DUMP_UNKNOWN_PACKET
 //#define DUMP_INVALID_PACKET
@@ -2730,6 +2731,30 @@
    return 0;
 }
 
+/*
+ * Helper fonction to refresh status after a bonus
+ * Derivated from Hulk pc_updatestatus
+ * if type == -1 refresh all
+ */ 
+void clif_sp_refresh(struct map_session_data *sd,int type){
+   int i=0, dtype=0;
+   ShowInfo("Entering clif_sp_refresh\n");
+   if(type != -1 && idb_exists(clif_sprefresh_db,type)){
+       dtype=idb_iget(clif_sprefresh_db,type);
+       if(dtype){
+           ShowInfo("Refreshing type(key)=%d => dtype(associate type)=%d, sp_atk1=%d, sp_atk2=%d\n",type,dtype,SP_ATK1,SP_ATK2);
+           clif_updatestatus(sd,dtype);
+       }
+   }
+   else { //refresh all
+       int size = db_size(clif_sprefresh_db);
+       for(i=0; i<size; i++){
+           dtype=idb_iget(clif_sprefresh_db,i);
+           clif_updatestatus(sd,dtype);
+       }
+   }
+}
+
 /// Notifies client of a character parameter change.
 /// 00b0 <var id>.W <value>.L (ZC_PAR_CHANGE)
 /// 00b1 <var id>.W <value>.L (ZC_LONGPAR_CHANGE)
@@ -15353,7 +15378,7 @@
    nullpo_retv(sd);
 
    WBUFW(buf,0) = 0x2cb;
-   safestrncpy( WBUFP(buf,2), name, 62 );
+   safestrncpy((char *) WBUFP(buf,2), name, 62 );
    WBUFW(buf,63) = num;
    if(flag) // A timer has changed or been added
        clif_send(buf,packet_len(0x2cb),&sd->bl,PARTY);
@@ -15390,7 +15415,7 @@
    nullpo_retv(sd);
 
    WBUFW(buf,0) = 0x2cd;
-   safestrncpy( WBUFP(buf,2), name, 62 );
+   safestrncpy((char *) WBUFP(buf,2), name, 62 );
    WBUFL(buf,63) = limit1;
    WBUFL(buf,67) = limit2;
    if(flag) // A timer has changed or been added
@@ -17396,6 +17421,64 @@
    ShowStatus("Using default packet version: "CL_WHITE"%d"CL_RESET".\n", clif_config.packet_db_ver);
 }
 
+void clif_create_sprefresh_db(void){
+   clif_sprefresh_db = idb_alloc(DB_OPT_BASE);
+   idb_iput(clif_sprefresh_db, SP_WEIGHT, SP_WEIGHT);
+   idb_iput(clif_sprefresh_db, SP_MAXWEIGHT, SP_MAXWEIGHT);
+   idb_iput(clif_sprefresh_db, SP_SPEED, SP_SPEED);
+   idb_iput(clif_sprefresh_db, SP_BASELEVEL, SP_BASELEVEL);
+   idb_iput(clif_sprefresh_db, SP_JOBLEVEL, SP_JOBLEVEL);
+   idb_iput(clif_sprefresh_db, SP_KARMA, SP_KARMA);
+   idb_iput(clif_sprefresh_db, SP_STATUSPOINT, SP_STATUSPOINT);
+   idb_iput(clif_sprefresh_db, SP_SKILLPOINT, SP_SKILLPOINT);
+   idb_iput(clif_sprefresh_db, SP_HIT, SP_HIT);
+   idb_iput(clif_sprefresh_db, SP_FLEE1, SP_FLEE1);
+   idb_iput(clif_sprefresh_db, SP_FLEE2, SP_FLEE2);
+   idb_iput(clif_sprefresh_db, SP_MAXHP, SP_MAXHP);
+   idb_iput(clif_sprefresh_db, SP_MAXSP, SP_MAXSP);
+   idb_iput(clif_sprefresh_db, SP_HP, SP_HP);
+   idb_iput(clif_sprefresh_db, SP_SP, SP_SP);
+   idb_iput(clif_sprefresh_db, SP_ASPD, SP_ASPD);
+   idb_iput(clif_sprefresh_db, SP_ATK1, SP_ATK1);
+   idb_iput(clif_sprefresh_db, SP_BASE_ATK, SP_ATK1);
+   idb_iput(clif_sprefresh_db, SP_DEF1, SP_DEF1);
+   idb_iput(clif_sprefresh_db, SP_MDEF1, SP_MDEF1);
+   idb_iput(clif_sprefresh_db, SP_ATK2, SP_ATK2);
+   idb_iput(clif_sprefresh_db, SP_DEF2, SP_DEF2);
+   idb_iput(clif_sprefresh_db, SP_MDEF2, SP_MDEF2);
+   idb_iput(clif_sprefresh_db, SP_CRITICAL, SP_CRITICAL);
+   idb_iput(clif_sprefresh_db, SP_MATK1, SP_MATK1);
+   idb_iput(clif_sprefresh_db, SP_MATK2, SP_MATK2);
+   idb_iput(clif_sprefresh_db, SP_ZENY, SP_ZENY);
+   idb_iput(clif_sprefresh_db, SP_BASEEXP, SP_BASEEXP);
+   idb_iput(clif_sprefresh_db, SP_JOBEXP, SP_JOBEXP);
+   idb_iput(clif_sprefresh_db, SP_NEXTBASEEXP, SP_NEXTBASEEXP);
+   idb_iput(clif_sprefresh_db, SP_NEXTJOBEXP, SP_NEXTJOBEXP);
+   idb_iput(clif_sprefresh_db, SP_USTR, SP_USTR);
+   idb_iput(clif_sprefresh_db, SP_UAGI, SP_UAGI);
+   idb_iput(clif_sprefresh_db, SP_UVIT, SP_UVIT);
+   idb_iput(clif_sprefresh_db, SP_UINT, SP_UINT);
+   idb_iput(clif_sprefresh_db, SP_UDEX, SP_UDEX);
+   idb_iput(clif_sprefresh_db, SP_ULUK, SP_ULUK);
+   idb_iput(clif_sprefresh_db, SP_ATTACKRANGE, SP_ATTACKRANGE);
+   idb_iput(clif_sprefresh_db, SP_STR, SP_STR);
+   idb_iput(clif_sprefresh_db, SP_AGI, SP_AGI);
+   idb_iput(clif_sprefresh_db, SP_VIT, SP_VIT);
+   idb_iput(clif_sprefresh_db, SP_INT, SP_INT);
+   idb_iput(clif_sprefresh_db, SP_DEX, SP_DEX);
+   idb_iput(clif_sprefresh_db, SP_LUK, SP_LUK);
+   idb_iput(clif_sprefresh_db, SP_CARTINFO, SP_CARTINFO);
+   
+   /*
+   int clif_sprefresh[] = {
+   SP_WEIGHT,SP_MAXWEIGHT,SP_SPEED,SP_BASELEVEL,SP_JOBLEVEL,SP_KARMA,
+   SP_MANNER,SP_STATUSPOINT,SP_SKILLPOINT,SP_HIT,SP_FLEE1,SP_FLEE2,SP_MAXHP,
+   SP_MAXSP,SP_HP,SP_SP,SP_ASPD,SP_ATK1,SP_DEF1,SP_MDEF1,SP_ATK2,SP_DEF2,SP_MDEF2,
+   SP_CRITICAL,SP_MATK1,SP_MATK2,SP_ZENY,SP_BASEEXP,SP_JOBEXP,SP_NEXTBASEEXP,SP_NEXTJOBEXP,
+   SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_ATTACKRANGE,SP_STR,SP_AGI,SP_VIT,SP_INT,SP_DEX,SP_LUK,SP_CARTINFO};
+   */
+}
+
 /*==========================================
  *
  *------------------------------------------*/
@@ -17415,6 +17498,7 @@
 
    //Using the packet_db file is the only way to set up packets now [Skotlex]
    packetdb_readdb();
+   clif_create_sprefresh_db();
 
    set_defaultparse(clif_parse);
    if( make_listen_bind(bind_ip,map_port) == -1 ) {
@@ -17431,4 +17515,5 @@
 
 void do_final_clif(void) {
    ers_destroy(delay_clearunit_ers);
+   db_destroy(clif_sprefresh_db);
 }
Index: src/map/clif.h
===================================================================
--- src/map/clif.h  (revision 408)
+++ src/map/clif.h  (working copy)
@@ -784,6 +784,6 @@
 void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char *msg, short color);
 
 #define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0;
+void clif_sp_refresh(struct map_session_data *sd,int type);
 
-
 #endif /* _CLIF_H_ */
Index: src/map/pc.c
===================================================================
--- src/map/pc.c    (revision 409)
+++ src/map/pc.c    (working copy)
@@ -8597,42 +8597,6 @@
 }
 
 /*==========================================
- * Temporary force update status like status_calc_bl_ but skip checkings to refresh [Aelys|sphkz] bugreport #66 [Fix 2 merde]
- *------------------------------------------*/
-void pc_updatestatus(struct map_session_data *sd)
-{  
-   clif_updatestatus(sd,SP_STR);   
-   clif_updatestatus(sd,SP_AGI);
-   clif_updatestatus(sd,SP_VIT);   
-   clif_updatestatus(sd,SP_INT);   
-   clif_updatestatus(sd,SP_DEX);
-   clif_updatestatus(sd,SP_LUK);   
-   clif_updatestatus(sd,SP_HIT);   
-   clif_updatestatus(sd,SP_FLEE1);     
-   clif_updatestatus(sd,SP_ASPD)
-   clif_updatestatus(sd,SP_SPEED);
-   clif_updatestatus(sd,SP_ATK1);
-   clif_updatestatus(sd,SP_DEF1);
-   clif_updatestatus(sd,SP_DEF2);
-   clif_updatestatus(sd,SP_ATK2);
-   clif_updatestatus(sd,SP_DEF2);
-   clif_updatestatus(sd,SP_DEF1);
-   clif_updatestatus(sd,SP_FLEE2);
-   clif_updatestatus(sd,SP_CRITICAL);
-   clif_updatestatus(sd,SP_MATK2);
-   clif_updatestatus(sd,SP_MATK1);
-   clif_updatestatus(sd,SP_MDEF1);
-   clif_updatestatus(sd,SP_MDEF2);
-   clif_updatestatus(sd,SP_MDEF2);
-   clif_updatestatus(sd,SP_MDEF1);
-   clif_updatestatus(sd,SP_ATTACKRANGE);
-   clif_updatestatus(sd,SP_MAXHP);
-   clif_updatestatus(sd,SP_MAXSP);
-   clif_updatestatus(sd,SP_HP);
-   clif_updatestatus(sd,SP_SP);
-}
-
-/*==========================================
  * Equip item on player sd at req_pos from inventory index n
  *------------------------------------------*/
 int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
@@ -8839,9 +8803,6 @@
        }
    }
    
-   //Force to refresh all status calculation on status windows [Aelys|sphkz] Temporary fix for bugreport#66
-   pc_updatestatus(sd);
-   
    sd->npc_item_flag = iflag;
 
    return 0;
@@ -9011,9 +8972,6 @@
        }
    }
    
-   //Force to refresh all status calculation on status windows [Aelys|sphkz] Temporary fix for bugreport#66
-   pc_updatestatus(sd);
-   
    sd->npc_item_flag = iflag;
 
    return 0;
Index: src/common/conf.h
===================================================================
--- src/common/conf.h   (revision 408)
+++ src/common/conf.h   (working copy)
@@ -5,7 +5,7 @@
 #define _CONF_H_
 
 #include "../common/cbasetypes.h"
-#include "libconfig.h"
+#include "../../3rdparty/libconfig/libconfig.h"
 
 int conf_read_file(config_t *config, const char *config_filename);
 int config_setting_copy(config_setting_t *parent, const config_setting_t *src);
 
Viewed 1658 times, submitted by lighta.