diff options
author | mc_cameri <mc_cameri@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-12-14 00:33:01 +0000 |
---|---|---|
committer | mc_cameri <mc_cameri@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-12-14 00:33:01 +0000 |
commit | 4aee20b0e1fdfb23d9336cea77a0985e463ea081 (patch) | |
tree | 0cca8570cea1e328d527952640287db50de5d6f6 | |
parent | c9e34e95d3d79d28927300684aaab6940fd03c9e (diff) | |
download | hercules-4aee20b0e1fdfb23d9336cea77a0985e463ea081.tar.gz hercules-4aee20b0e1fdfb23d9336cea77a0985e463ea081.tar.bz2 hercules-4aee20b0e1fdfb23d9336cea77a0985e463ea081.tar.xz hercules-4aee20b0e1fdfb23d9336cea77a0985e463ea081.zip |
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@566 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog.txt | 5 | ||||
-rw-r--r-- | src/common/grfio.c | 8 | ||||
-rw-r--r-- | src/common/showmsg.c | 16 | ||||
-rw-r--r-- | src/common/showmsg.h | 12 | ||||
-rw-r--r-- | src/map/chrif.c | 14 | ||||
-rw-r--r-- | src/map/clif.c | 8 | ||||
-rw-r--r-- | src/map/guild.c | 4 | ||||
-rw-r--r-- | src/map/itemdb.c | 9 | ||||
-rw-r--r-- | src/map/map.c | 44 | ||||
-rw-r--r-- | src/map/mob.c | 3 | ||||
-rw-r--r-- | src/map/npc.c | 9 | ||||
-rw-r--r-- | src/map/pc.c | 17 | ||||
-rw-r--r-- | src/map/skill.c | 6 |
13 files changed, 113 insertions, 42 deletions
diff --git a/Changelog.txt b/Changelog.txt index a7c1f33c1..af2df756c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,9 @@ Date Added 12/14 + * Replaced the way map loading was displayed into a progress-like way [MC Cameri] + * Fixed some typos in _ShowMessage() [MC Cameri] + * Replaced lots of more printf's in map-server with _ShowMessage() [MC Cameri] + * Added constants for console colors in showmsg.h [MC Cameri] * src/char_sql/int_guild.c:56 - t_mes2 was not big enough causing stack overrun's, corruptions, and crashes [MouseJstr] * common/mmo.h: changed base_level and job_level to unsigned int to increase max levels [Codemaster] @@ -28,6 +32,7 @@ Date Added rollback - fix by Freya [celest] * Removed 'type' paramater from pc_unequipitem to use 'flag' instead[celest] * Moved unequip checking code from clif.c to pc.c [celest] +>>>>>>> .r565 * Replaced many printf's in map-server with _ShowMessage(). [MC Cameri] * Skill timers for skills with id's higher then 450 were corrupting memory [MouseJstr] diff --git a/src/common/grfio.c b/src/common/grfio.c index 2ba701632..d3d39c106 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -614,7 +614,8 @@ static int grfio_entryread(char *gfname,int gentry) fp = fopen(gfname,"rb"); if(fp==NULL) { - printf("%s not found (grfio_entryread)\n",gfname); + sprintf(tmp_output,"GRF Data File not found: '\033[1;29m%s\033[0;0m'.\n",gfname); + ShowWarning(tmp_output); return 1; // 1:not found error } @@ -837,7 +838,8 @@ int grfio_add(char *fname) exit(1); } - printf("%s file reading...\n",fname); +// sprintf(tmp_output,"Reading GRF File: '%s'.\n",fname); +// ShowStatus(tmp_output); if (gentry_entrys>=gentry_maxentry) { char **new_gentry = (char**)realloc( @@ -924,7 +926,7 @@ void grfio_init(char *fname) } fclose(data_conf); - sprintf(tmp_output,"Done reading GRF File: '\033[1;29m%s\033[0;0m'.\n",fname); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n",fname); ShowStatus(tmp_output); } // end of reading grf-files.txt diff --git a/src/common/showmsg.c b/src/common/showmsg.c index e96f97e22..32b9dd22c 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -14,12 +14,12 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri char prefix[40]; char *output; if (strlen(string) <= 0) { - ShowError("Empty string passed to ShowMessage().\n"); + ShowError("Empty string passed to _ShowMessage().\n"); return 1; } switch (flag) { case MSG_STATUS: //Bright Green (To inform about good things) - strcpy(prefix,"\033[1;32m[Status]\033[0;0m:"); + strcpy(prefix,CL_GREEN"[Status]"CL_RESET":"); break; /* //Do we really need this now? [MC Cameri] case MSG_SQL: //Bright Violet (For dumping out anything related with SQL) @@ -27,19 +27,19 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri break; */ case MSG_INFORMATION: //Bright White (Variable information) - strcpy(prefix,"\033[1;29m[Info]\033[0;0m:"); + strcpy(prefix,CL_WHITE"[Info]"CL_RESET":"); break; case MSG_NOTICE: //Bright White (Less than a warning) - strcpy(prefix,"\033[1;29m[Notice]\033[0;0m:"); + strcpy(prefix,CL_WHITE"[Notice]"CL_RESET":"); break; case MSG_WARNING: //Bright Yellow - strcpy(prefix,"\033[1;33m[Warning]\033[0;0m:"); + strcpy(prefix,CL_YELLOW"[Warning]"CL_RESET":"); break; case MSG_ERROR: //Bright Red (Regular errors) - strcpy(prefix,"\033[1;31m[Error]\033[0;0m:"); + strcpy(prefix,CL_RED"[Error]"CL_RESET":"); break; case MSG_FATALERROR: //Bright Red (Fatal errors, abort(); if possible) - strcpy(prefix,"\033[1;31m[Fatal Error]\033[0;0m:"); + strcpy(prefix,CL_RED"[Fatal Error]"CL_RESET":"); break; default: ShowError("In function _ShowMessage() -> Invalid flag passed.\n"); @@ -48,7 +48,7 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // +2: space and a \0 if (output == NULL) { return 1; -// abort(); // Kill server? Deadly +// exit(1); // Kill server? Deadly } strcpy(output,prefix); strcat(output," "); diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 03ffe310b..59bd6a090 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -1,6 +1,18 @@ #ifndef _SHOWMSG_H_ #define _SHOWMSG_H_ +#define CL_RESET "\033[0;0m" +#define CL_NORMAL CL_RESET +#define CL_NONE CL_RESET +#define CL_WHITE "\033[1;29m" +#define CL_GRAY "\033[1;30m" +#define CL_RED "\033[1;31m" +#define CL_GREEN "\033[1;32m" +#define CL_YELLOW "\033[1;33m" +#define CL_BLUE "\033[1;34m" +#define CL_MAGENTA "\033[1;35m" +#define CL_CYAN "\033[1;36m" + extern char tmp_output[1024]; enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR}; diff --git a/src/map/chrif.c b/src/map/chrif.c index 3d3f7d233..81c6744c2 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -23,6 +23,7 @@ #include "npc.h" #include "pc.h" #include "nullpo.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -244,13 +245,16 @@ int chrif_connectack(int fd) printf("Connected to char-server failed %d.\n", RFIFOB(fd,2)); exit(1); } - printf("Connected to char-server (connection #%d).\n", fd); + sprintf(tmp_output,"Successfully connected to Char-Server (Connection #%d).\n",fd); + ShowStatus(tmp_output); chrif_state = 1; chrif_sendmap(fd); - printf("chrif: OnCharIfInit event done. (%d events)\n", npc_event_doall("OnCharIfInit")); - printf("chrif: OnInterIfInit event done. (%d events)\n", npc_event_doall("OnInterIfInit")); + sprintf(tmp_output,"Event '"CL_WHITE"OnCharIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnCharIfInit")); + ShowStatus(tmp_output); + sprintf(tmp_output,"Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); + ShowStatus(tmp_output); // <Agit> Run Event [AgitInit] // printf("NPC_Event:[OnAgitInit] do (%d) events (Agit Initialize).\n", npc_event_doall("OnAgitInit")); @@ -856,8 +860,8 @@ int chrif_chardisconnect(struct map_session_data *sd) */ int chrif_recvgmaccounts(int fd) { - printf("From login-server: receiving of %d GM accounts information.\n", pc_read_gm_account(fd)); - + sprintf(tmp_output,"From login-server: receiving information of '"CL_WHITE"%d"CL_RESET"' GM accounts.\n", pc_read_gm_account(fd)); + ShowInfo(tmp_output); return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 7e4605807..1f7130676 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -24,6 +24,7 @@ #include "../common/malloc.h" #include "../common/version.h" #include "../common/nullpo.h" +#include "../common/showmsg.h" #include "map.h" #include "chrif.h" @@ -10107,15 +10108,16 @@ static int clif_parse(int fd) { if (chrif_isconnect()) clif_quitsave(fd, sd); if (sd->status.name != NULL) - printf("Player [%s] has logged off your server.\n", sd->status.name); // Player logout display [Valaris] + sprintf(tmp_output,"%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris] else - printf("Player with account [%d] has logged off your server.\n", sd->bl.id); // Player logout display [Yor] + sprintf(tmp_output,"%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id); // Player logout display [Yor] } else if (sd) { // not authentified! (refused by char-server or disconnect before to be authentified) - printf("Player with account [%d] has logged off your server (not auth account).\n", sd->bl.id); // Player logout display [Yor] + sprintf(tmp_output,"Player not authenticated with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", sd->bl.id); // Player logout display [Yor] if (chrif_isconnect()) clif_quitsave(fd, sd); sd = 0; } + ShowInfo(tmp_output); close(fd); if (sd) // 追加 map_deliddb(&sd->bl); // 追加 diff --git a/src/map/guild.c b/src/map/guild.c index 2937940c3..ec2a636b9 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -18,6 +18,7 @@ #include "intif.h" #include "clif.h" #include "skill.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -127,7 +128,8 @@ static int guild_read_castledb(void) ln++; } fclose(fp); - printf("read db/castle_db.txt done (count=%d)\n",ln); + sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/castle_db.txt"); + ShowStatus(tmp_output); return 0; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index cd915b92e..38795547e 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -552,7 +552,8 @@ static int itemdb_read_itemnametable(void) p++; } free(buf); - printf("read data\\idnum2itemdisplaynametable.txt done.\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","data\\idnum2itemdisplaynametable.txt"); + ShowStatus(tmp_output); return 0; } @@ -587,7 +588,8 @@ static int itemdb_read_cardillustnametable(void) p++; } free(buf); - printf("read data\\num2cardillustnametable.txt done.\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","data\\num2cardillustnametable.txt"); + ShowStatus(tmp_output); return 0; } @@ -631,7 +633,8 @@ static int itemdb_read_noequip(void) } fclose(fp); - printf("read db/item_noequip.txt done (count=%d)\n",ln); + sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/item_noequip.txt"); + ShowStatus(tmp_output); return 0; } #ifndef TXT_ONLY diff --git a/src/map/map.c b/src/map/map.c index 282d2795b..c00845158 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -104,6 +104,8 @@ static int online_timer(int,unsigned int,int,int); int CHECK_INTERVAL = 3600000; // [Valaris] int check_online_timer=0; // [Valaris] +static int pos = 0; + #endif /* not TXT_ONLY */ #define USE_AFM @@ -1588,16 +1590,26 @@ static int map_readmap(int m,char *fn, char *alias) { int x,y,xs,ys; struct gat_1cell {float high[4]; int type;} *p=NULL; int wh; + int i; + int e = 0; + size_t size; - + char progress[21] = " "; // read & convert fn gat=grfio_read(fn); if(gat==NULL) return -1; - - printf("\rLoading Maps [%d/%d]: %-50s ",m,map_num,fn); - fflush(stdout); - + //printf("\rLoading Maps [%d/%d]: %-50s ",m,map_num,fn); + if (map_num) { //avoid map-server crashing if there are 0 maps + printf("\r"); + ShowStatus("Progress: "); + i=m*20/420; + printf("["); + for (e=0;e<i;e++) progress[e] = '#'; + printf(progress); + printf("] Working: ["); + fflush(stdout); + } map[m].m=m; xs=map[m].xs=*(int*)(gat+6); ys=map[m].ys=*(int*)(gat+10); @@ -1645,8 +1657,12 @@ static int map_readmap(int m,char *fn, char *alias) { *------------------------------------------ */ int map_readallmap(void) { + ShowStatus("Loading Maps...\n"); int i,maps_removed=0; char fn[256]; + char c = '-'; + time_t last_time = time(0); + int busy = 0; #ifdef USE_AFM FILE *afm_file; #endif @@ -1681,16 +1697,28 @@ int map_readallmap(void) { if(map_readmap(i,fn, p) == -1) { map_delmap(map[i].name); maps_removed++; + } else { + if (last_time != time(0)) { + last_time = time(0); + switch(busy) { + case 0: c='\\'; busy++; break; + case 1: c='|'; busy++; break; + case 2: c='/'; busy++; break; + case 3: c='-'; busy=0; + } + } + printf("%c]",c); + fflush(stdout); } } } free(waterlist); printf("\r"); - snprintf(tmp_output,sizeof(tmp_output),"Maps Loaded: \033[1;29m%d\033[0;0m %50s\n",map_num,""); + snprintf(tmp_output,sizeof(tmp_output),"Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps.%50s\n",map_num,""); ShowInfo(tmp_output); if (maps_removed) { - snprintf(tmp_output,sizeof(tmp_output),"Maps Removed: %d\n",maps_removed); + snprintf(tmp_output,sizeof(tmp_output),"Maps Removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); ShowNotice(tmp_output); } return 0; @@ -2386,13 +2414,13 @@ int do_init(int argc, char *argv[]) { do_init_itemdb(); do_init_mob(); // npcの初期化時内でmob_spawnして、mob_dbを参照するのでinit_npcより先 do_init_script(); - do_init_npc(); do_init_pc(); do_init_party(); do_init_guild(); do_init_storage(); do_init_skill(); do_init_pet(); + do_init_npc(); #ifndef TXT_ONLY /* mail system [Valaris] */ if(battle_config.mail_system) diff --git a/src/map/mob.c b/src/map/mob.c index a7516c784..a057d12e1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3959,7 +3959,8 @@ static int mob_readdb_mobavail(void) ln++; } fclose(fp); - printf("read db/mob_avail.txt done (count=%d)\n",ln); + sprintf(tmp_output,"Done reading '\033[1;29m%d\033[0;0m' entries in '\033[1;29m%s\033[0;0m'.\n",ln,"db/mob_avail.txt"); + ShowStatus(tmp_output); return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index 294058f64..8f4716ca2 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2219,6 +2219,7 @@ void ev_release(struct dbn *db, int which) */ int do_init_npc(void) { + ShowStatus("Loading NPCs...\n"); struct npc_src_list *nsl; FILE *fp; char line[1024]; @@ -2297,8 +2298,14 @@ int do_init_npc(void) // printf("\rLoading NPCs [%d]: %-54s",npc_id-START_NPC_NUM,nsl->name); // fflush(stdout); } - printf("\rNPCs Loaded: %d [Warps:%d Shops:%d Scripts:%d Mobs:%d]\n", + printf("\r"); + sprintf(tmp_output,"Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:\n\t-'" + CL_WHITE"%d"CL_RESET"' Warps\n\t-'" + CL_WHITE"%d"CL_RESET"' Shops\n\t-'" + CL_WHITE"%d"CL_RESET"' Scripts\n\t-'" + CL_WHITE"%d"CL_RESET"' Mobs\n", npc_id-START_NPC_NUM,npc_warp,npc_shop,npc_script,npc_mob); + ShowInfo(tmp_output); add_timer_func_list(npc_walktimer,"npc_walktimer"); // [Valaris] add_timer_func_list(npc_event_timer,"npc_event_timer"); diff --git a/src/map/pc.c b/src/map/pc.c index 3cb78e65a..7c5a8c077 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -826,13 +826,15 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars pc_calcstatus(sd,1); if (pc_isGM(sd)) - printf("Connection accepted: character '%s' (account: %d; GM level %d).\n", sd->status.name, sd->status.account_id, pc_isGM(sd)); + sprintf(tmp_output,"GM Character '"CL_WHITE"%s"CL_RESET"' logged in. (Acc. ID: '"CL_WHITE"%d"CL_RESET"', GM Level '"CL_WHITE"%d"CL_RESET"').\n", sd->status.name, sd->status.account_id, pc_isGM(sd)); else - printf("Connection accepted: Character '%s' (account: %d).\n", sd->status.name, sd->status.account_id); - + sprintf(tmp_output,"Character '"CL_WHITE"%s"CL_RESET"' logged in. (Account ID: '"CL_WHITE"%d"CL_RESET"').\n", sd->status.name, sd->status.account_id); + ShowInfo(tmp_output); //printf("pc: OnPCLogin event done. (%d events)\n", npc_event_doall("OnPCLogin") ); - if (npc_name2id("PCLoginEvent")) + if (npc_name2id("PCLoginEvent")) { run_script(npc_name2id("PCLoginEvent")->u.scr.script,0,sd->bl.id,npc_name2id("PCLoginEvent")->bl.id); // PCLoginNPC + ShowStatus("Event '\033[1;29mPCLoginEvent\033[0;0m' executed.\n"); + } // Send friends list clif_friends_list_send(sd); @@ -857,8 +859,8 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars fclose(fp); } else if(battle_config.error_log) { - sprintf(buf, "%s not found\n", motd_txt); - ShowWarning (buf); + sprintf(tmp_output, "In function pc_atuhok() -> File '"CL_WHITE"%s"CL_RESET"' not found.\n", motd_txt); + ShowWarning(tmp_output); } } @@ -7808,7 +7810,8 @@ int pc_readdb(void) break; } fclose(fp); - printf("read db/job_db2-2.txt done\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/job_db2-2.txt"); + ShowStatus(tmp_output); // スキルツリ? memset(skill_tree,0,sizeof(skill_tree)); diff --git a/src/map/skill.c b/src/map/skill.c index 3cdc4a8f4..3a0d02c8d 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -11531,7 +11531,8 @@ int skill_readdb(void) skill_db[i].blewcount[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } fclose(fp); - printf("read db/skill_db.txt done\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_db.txt"); + ShowStatus(tmp_output); fp=fopen("db/skill_require_db.txt","r"); if(fp==NULL){ @@ -11670,7 +11671,8 @@ int skill_readdb(void) skill_db[i].amount[9]=atoi(split[29]); } fclose(fp); - printf("read db/skill_require_db.txt done\n"); + sprintf(tmp_output,"Done reading '\033[1;29m%s\033[0;0m'.\n","db/skill_cast_db.txt"); + ShowStatus(tmp_output); /* キャスティングデ?タベ?ス */ fp=fopen("db/skill_cast_db.txt","r"); |