summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-27 10:36:30 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-27 10:36:30 +0000
commitb3574d7f0a8565ecc46bc6ba8d128688156b6331 (patch)
tree1aff9636ac994ff3bece032421cc23a6d92efd1f /src/map
parent249b427c3ce9b90cbec7aa50e3b04100f3f95d1c (diff)
downloadhercules-b3574d7f0a8565ecc46bc6ba8d128688156b6331.tar.gz
hercules-b3574d7f0a8565ecc46bc6ba8d128688156b6331.tar.bz2
hercules-b3574d7f0a8565ecc46bc6ba8d128688156b6331.tar.xz
hercules-b3574d7f0a8565ecc46bc6ba8d128688156b6331.zip
* Added use dynamic allocation when loading the msg_table
* Refresh the client when day comes to get rid of the night effect * Changed @refresh to fake map loading, but without teleporting side effect * Updated SQL file for the item_db git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1307 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c38
-rw-r--r--src/map/atcommand.h1
-rw-r--r--src/map/clif.c8
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/map.c1
-rw-r--r--src/map/pc.c8
6 files changed, 48 insertions, 9 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 96a0ee29a..bc11123b9 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -39,7 +39,8 @@
static char command_symbol = '@'; // first char of the commands (by [Yor])
-char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
+#define MAX_MSG 1000
+char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
#define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
ACMD_FUNC(broadcast);
@@ -660,7 +661,7 @@ int lowtohigh_compare (const void * a, const void * b)
// Return the message string of the specified number by [Yor]
//-----------------------------------------------------------
char * msg_txt(int msg_number) {
- if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
+ if (msg_number >= 0 && msg_number < MAX_MSG &&
msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
return msg_table[msg_number];
@@ -910,12 +911,15 @@ int msg_config_read(const char *cfgName) {
int msg_number;
char line[1024], w1[1024], w2[1024];
FILE *fp;
+ static int called = 1;
if ((fp = fopen(cfgName, "r")) == NULL) {
printf("Messages file not found: %s\n", cfgName);
return 1;
}
+ if ((--called) == 0)
+ memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
while(fgets(line, sizeof(line)-1, fp)) {
if (line[0] == '/' && line[1] == '/')
continue;
@@ -924,9 +928,13 @@ int msg_config_read(const char *cfgName) {
msg_config_read(w2);
} else {
msg_number = atoi(w1);
- if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
- strcpy(msg_table[msg_number], w2);
+ if (msg_number >= 0 && msg_number < MAX_MSG) {
+ if (msg_table[msg_number] != NULL)
+ aFree(msg_table[msg_number]);
+ msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
+ strcpy(msg_table[msg_number],w2);
// printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
+ }
}
}
}
@@ -936,6 +944,17 @@ int msg_config_read(const char *cfgName) {
}
/*==========================================
+ * Cleanup Message Data
+ *------------------------------------------
+ */
+void do_final_msg () {
+ int i;
+ for (i = 0; i < MAX_MSG; i++)
+ aFree(msg_table[i]);
+ return;
+}
+
+/*==========================================
*
*------------------------------------------
*/
@@ -4495,8 +4514,12 @@ int atcommand_day(
night_flag = 0; // 0=day, 1=night [Yor]
for(i = 0; i < fd_max; i++) {
if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
- pl_sd->opt2 &= ~STATE_BLIND;
- clif_changeoption(&pl_sd->bl);
+ if (battle_config.night_darkness_level > 0)
+ clif_refresh (pl_sd);
+ else {
+ pl_sd->opt2 &= ~STATE_BLIND;
+ clif_changeoption(&pl_sd->bl);
+ }
clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
}
}
@@ -8104,7 +8127,8 @@ int atcommand_refresh(
const char* command, const char* message)
{
nullpo_retr(-1, sd);
- pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
+ //pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
+ clif_refresh(sd);
return 0;
}
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index bdc4f429d..14a912ab1 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -275,6 +275,7 @@ int atcommand_recall(const int fd, struct map_session_data* sd, const char* comm
int atcommand_config_read(const char *cfgName);
int msg_config_read(const char *cfgName);
+void do_final_msg();
char *estr_lower(char *str);
diff --git a/src/map/clif.c b/src/map/clif.c
index 74d26dbac..d9665b527 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7318,6 +7318,14 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) {
return 0;
}
+
+// refresh the client's screen, getting rid of any effects
+int clif_refresh(struct map_session_data *sd) {
+ nullpo_retr(-1, sd);
+ clif_changemap(sd,sd->mapname,sd->bl.x,sd->bl.y);
+ return 0;
+}
+
// ------------
// clif_parse_*
// ------------
diff --git a/src/map/clif.h b/src/map/clif.h
index 196050c0d..b23eed5a6 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -102,6 +102,7 @@ int clif_changechatowner(struct chat_data*,struct map_session_data*); // chat
int clif_clearchat(struct chat_data*,int); // area or fd
int clif_leavechat(struct chat_data*,struct map_session_data*); // chat
int clif_changechatstatus(struct chat_data*); // chat
+int clif_refresh(struct map_session_data*); // self
void clif_emotion(struct block_list *bl,int type);
void clif_talkiebox(struct block_list *bl,char* talkie);
diff --git a/src/map/map.c b/src/map/map.c
index 205c21cd2..db2831cf5 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3185,6 +3185,7 @@ void do_final(void) {
do_final_party();
do_final_pc();
do_final_pet();
+ do_final_msg();
for (i=0; i<map_num; i++) {
if(map[i].gat) aFree(map[i].gat);
diff --git a/src/map/pc.c b/src/map/pc.c
index 768098afb..7fb2bb42b 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -7014,8 +7014,12 @@ int map_day_timer(int tid, unsigned int tick, int id, int data) { // by [yor]
night_flag = 0; // 0=day, 1=night [Yor]
for(i = 0; i < fd_max; i++) {
if (session[i] && (pl_sd = (struct map_session_data *) session[i]->session_data) && pl_sd->state.auth) {
- pl_sd->opt2 &= ~STATE_BLIND;
- clif_changeoption(&pl_sd->bl);
+ if (battle_config.night_darkness_level > 0)
+ clif_refresh (pl_sd);
+ else {
+ pl_sd->opt2 &= ~STATE_BLIND;
+ clif_changeoption(&pl_sd->bl);
+ }
clif_wis_message(pl_sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1);
}
}