Skip to content

Commit

Permalink
MOTD redesign
Browse files Browse the repository at this point in the history
much more flexible, as per community suggestion in
http://hercules.ws/board/topic/320-motd-change-suggestion/
dropped motd_type config
new motd is at npc/MOTD.txt
dropped @motd, @gmotd commands

Signed-off-by: shennetsind <ind@henn.et>
  • Loading branch information
shennetsind committed May 17, 2013
1 parent 3820bd7 commit 9080a58
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 146 deletions.
3 changes: 0 additions & 3 deletions conf/battle/client.conf
Expand Up @@ -87,9 +87,6 @@ summer_ignorepalette: no
// Set this to yes if your cloth palettes pack doesn't has Hanbok palettes (or has less than the other jobs)
hanbok_ignorepalette: no

// Set this to 1 if your clients have langtype problems and can't display motd properly
motd_type: 0

// Show Hercules version to users when the login?
display_version: no

Expand Down
1 change: 0 additions & 1 deletion conf/help.txt
Expand Up @@ -7,7 +7,6 @@

help: "Params: <command>\n" "Shows help for specified command."
noask: "Auto rejects deals/invites."
gmotd: "Broadcasts the Message of The Day to all players."
me: "Params: <message>\n" "Displays normal text as a message in this format: *name message* (like /me in mIRC)."
fakename: "Params: <name>\n" "Changes your name to your choice temporarily."
npctalk: "Params: <NPC name> <message>\n" "Forces a NPC to display a message in normal chat."
Expand Down
2 changes: 0 additions & 2 deletions conf/motd.txt

This file was deleted.

4 changes: 2 additions & 2 deletions db/pre-re/map_zone_db.conf
Expand Up @@ -47,8 +47,8 @@ zones: (
skill_damage_cap: {
//Exemple Below caps firebolt damage in maps within this zone to a maximum 50 damage,
// (depends on HMAP_ZONE_DAMAGE_CAP_TYPE in src/config/core.h)
// to players and monsters.
//MG_FIREBOLT: (50,"PLAYER | MONSTER")
// when cast vs players and monsters.
//MG_COLDBOLT: (50,"PLAYER | MONSTER")
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions db/re/map_zone_db.conf
Expand Up @@ -47,8 +47,8 @@ zones: (
skill_damage_cap: {
//Exemple Below caps firebolt damage in maps within this zone to a maximum 50 damage,
// (depends on HMAP_ZONE_DAMAGE_CAP_TYPE in src/config/core.h)
// to players and monsters.
//MG_FIREBOLT: (50,"PLAYER | MONSTER")
// when cast vs players and monsters.
//MG_COLDBOLT: (50,"PLAYER | MONSTER")
}
},
{
Expand Down
15 changes: 15 additions & 0 deletions npc/MOTD.txt
@@ -0,0 +1,15 @@
//====================================================
//= _ _ _
//= | | | | | |
//= | |_| | ___ _ __ ___ _ _| | ___ ___
//= | _ |/ _ \ '__/ __| | | | |/ _ \/ __|
//= | | | | __/ | | (__| |_| | | __/\__ \
//= \_| |_/\___|_| \___|\__,_|_|\___||___/
//=
//= http://hercules.ws/board/
//====================================================
// run when any character logs in, attached to them.
- script HerculesMOTD -1,{
message strcharinfo(0),"Welcome to Hercules! Enjoy! Please report any bugs you find.";
end;
}
1 change: 1 addition & 0 deletions npc/scripts_athena.conf
@@ -1,3 +1,4 @@
npc: npc/MOTD.txt
// --------------------------------------------------------------
// - Core Scripts -
// --------------------------------------------------------------
Expand Down
54 changes: 1 addition & 53 deletions src/map/atcommand.c
Expand Up @@ -3713,16 +3713,6 @@ ACMD(reloadpcdb)
return true;
}

/*==========================================
* @reloadmotd - reloads motd.txt
*------------------------------------------*/
ACMD(reloadmotd)
{
pc_read_motd();
clif->message(fd, msg_txt(268));
return true;
}

/*==========================================
* @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
*------------------------------------------*/
Expand Down Expand Up @@ -6593,47 +6583,7 @@ ACMD(identify)
return true;
}

/*==========================================
* @gmotd (Global MOTD)
* by davidsiaw :P
*------------------------------------------*/
ACMD(gmotd)
{
FILE* fp;

if( ( fp = fopen(motd_txt, "r") ) != NULL )
{
char buf[CHAT_SIZE_MAX];
size_t len;

while( fgets(buf, sizeof(buf), fp) )
{
if( buf[0] == '/' && buf[1] == '/' )
{
continue;
}

len = strlen(buf);

while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
{// strip trailing EOL characters
len--;
}

if( len )
{
buf[len] = 0;

intif_broadcast(buf, len+1, 0);
}
}
fclose(fp);
}
return true;
}

ACMD(misceffect)
{
ACMD(misceffect) {
int effect = 0;
nullpo_retr(-1, sd);
if (!message || !*message)
Expand Down Expand Up @@ -9553,7 +9503,6 @@ void atcommand_basecommands(void) {
ACMD_DEF(reloadbattleconf),
ACMD_DEF(reloadstatusdb),
ACMD_DEF(reloadpcdb),
ACMD_DEF(reloadmotd),
ACMD_DEF(mapinfo),
ACMD_DEF(dye),
ACMD_DEF2("hairstyle", hair_style),
Expand Down Expand Up @@ -9615,7 +9564,6 @@ void atcommand_basecommands(void) {
ACMD_DEF(refresh),
ACMD_DEF(refreshall),
ACMD_DEF(identify),
ACMD_DEF(gmotd),
ACMD_DEF(misceffect),
ACMD_DEF(mobsearch),
ACMD_DEF(cleanmap),
Expand Down
1 change: 0 additions & 1 deletion src/map/battle.c
Expand Up @@ -5820,7 +5820,6 @@ static const struct _battle_data {
{ "mobs_level_up_exp_rate", &battle_config.mobs_level_up_exp_rate, 1, 1, INT_MAX, },
{ "pk_min_level", &battle_config.pk_min_level, 55, 1, INT_MAX, },
{ "skill_steal_max_tries", &battle_config.skill_steal_max_tries, 0, 0, UCHAR_MAX, },
{ "motd_type", &battle_config.motd_type, 0, 0, 1, },
{ "finding_ore_rate", &battle_config.finding_ore_rate, 100, 0, INT_MAX, },
{ "exp_calc_type", &battle_config.exp_calc_type, 0, 0, 1, },
{ "exp_bonus_attacker", &battle_config.exp_bonus_attacker, 25, 0, INT_MAX, },
Expand Down
1 change: 0 additions & 1 deletion src/map/battle.h
Expand Up @@ -322,7 +322,6 @@ struct Battle_Config {
int mobs_level_up_exp_rate; // [Valaris]
int pk_min_level; // [celest]
int skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus]
int motd_type; // [celest]
int finding_ore_rate; // orn
int exp_calc_type;
int exp_bonus_attacker;
Expand Down
2 changes: 1 addition & 1 deletion src/map/chrif.c
Expand Up @@ -1245,7 +1245,7 @@ int chrif_load_scdata(int fd) {
}

/*==========================================
* Send rates and motd to char server [Wizputer]
* Send rates to char server [Wizputer]
* S 2b16 <base rate>.L <job rate>.L <drop rate>.L
*------------------------------------------*/
int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
Expand Down
4 changes: 1 addition & 3 deletions src/map/map.c
Expand Up @@ -151,7 +151,6 @@ struct map_cache_map_info {
};

char db_path[256] = "db";
char motd_txt[256] = "conf/motd.txt";
char help_txt[256] = "conf/help.txt";
char help2_txt[256] = "conf/help2.txt";
char charhelp_txt[256] = "conf/charhelp.txt";
Expand Down Expand Up @@ -3340,8 +3339,6 @@ int map_config_read(char *cfgName)
minsave_interval = 1;
} else if (strcmpi(w1, "save_settings") == 0)
save_settings = atoi(w2);
else if (strcmpi(w1, "motd_txt") == 0)
strcpy(motd_txt, w2);
else if (strcmpi(w1, "help_txt") == 0)
strcpy(help_txt, w2);
else if (strcmpi(w1, "help2_txt") == 0)
Expand Down Expand Up @@ -5206,6 +5203,7 @@ void load_defaults(void) {
ircbot_defaults();
log_defaults();
map_defaults();
npc_defaults();
script_defaults();
searchstore_defaults();
skill_defaults();
Expand Down
1 change: 0 additions & 1 deletion src/map/map.h
Expand Up @@ -705,7 +705,6 @@ extern int night_flag; // 0=day, 1=night [Yor]
extern int enable_spy; //Determines if @spy commands are active.
extern char db_path[256];

extern char motd_txt[];
extern char help_txt[];
extern char help2_txt[];
extern char charhelp_txt[];
Expand Down
9 changes: 9 additions & 0 deletions src/map/npc.c
Expand Up @@ -3899,6 +3899,8 @@ int npc_reload(void) {

map_zone_init();

npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */

//Re-read the NPC Script Events cache.
npc_read_event_script();

Expand Down Expand Up @@ -4031,6 +4033,8 @@ int do_init_npc(void)

map_zone_init();

npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */

// set up the events cache
memset(script_event, 0, sizeof(script_event));
npc_read_event_script();
Expand Down Expand Up @@ -4062,3 +4066,8 @@ int do_init_npc(void)

return 0;
}
void npc_defaults(void) {
npc = &npc_s;

npc->motd = NULL;
}
16 changes: 14 additions & 2 deletions src/map/npc.h
@@ -1,5 +1,6 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams

#ifndef _NPC_H_
#define _NPC_H_
Expand Down Expand Up @@ -188,4 +189,15 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c

bool npc_unloadfile( const char* path );

/* npc.c interface (barely started/WIP) */
struct npc_interface {
/* */
struct npc_data *motd;
/* */
} npc_s;

struct npc_interface *npc;

void npc_defaults(void);

#endif /* _NPC_H_ */
76 changes: 3 additions & 73 deletions src/map/pc.c
Expand Up @@ -68,9 +68,6 @@ struct fame_list taekwon_fame_list[MAX_FAME_LIST];

static unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_GARMENT,EQP_AMMO};

#define MOTD_LINE_SIZE 128
static char motd_text[MOTD_LINE_SIZE][CHAT_SIZE_MAX]; // Message of the day buffer [Valaris]

//Links related info to the sd->hate_mob[]/sd->feel_map[] entries
const struct sg_data sg_info[MAX_PC_FEELHATE] = {
{ SG_SUN_ANGER, SG_SUN_BLESS, SG_SUN_COMFORT, "PC_FEEL_SUN", "PC_HATE_MOB_SUN", is_day_of_sun },
Expand Down Expand Up @@ -1067,15 +1064,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sprintf(buf,"Unknown Version");
clif->message(sd->fd, buf);
}

// Message of the Day [Valaris]
for(i=0; motd_text[i][0] && i < MOTD_LINE_SIZE; i++) {
if (battle_config.motd_type)
clif->disp_onlyself(sd,motd_text[i],strlen(motd_text[i]));
else
clif->message(sd->fd, motd_text[i]);
}


// message of the limited time of the account
if (expiration_time != 0) { // don't display if it's unlimited or unknow value
char tmpstr[1024];
Expand Down Expand Up @@ -1254,6 +1243,8 @@ int pc_reg_received(struct map_session_data *sd)
clif->changeoption(&sd->bl);
}

if( npc->motd ) /* [Ind/Hercules] */
run_script(npc->motd->u.scr.script, 0, sd->bl.id, fake_nd->bl.id);

return 1;
}
Expand Down Expand Up @@ -9732,66 +9723,6 @@ int pc_readdb(void)
return 0;
}

// Read MOTD on startup. [Valaris]
int pc_read_motd(void)
{
FILE* fp;

// clear old MOTD
memset(motd_text, 0, sizeof(motd_text));

// read current MOTD
if( ( fp = fopen(motd_txt, "r") ) != NULL )
{
char* buf, * ptr;
unsigned int lines = 0, entries = 0;
size_t len;

while( entries < MOTD_LINE_SIZE && fgets(motd_text[entries], sizeof(motd_text[entries]), fp) )
{
lines++;

buf = motd_text[entries];

if( buf[0] == '/' && buf[1] == '/' )
{
continue;
}

len = strlen(buf);

while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
{// strip trailing EOL characters
len--;
}

if( len )
{
buf[len] = 0;

if( ( ptr = strstr(buf, " :") ) != NULL && ptr-buf >= NAME_LENGTH )
{// crashes newer clients
ShowWarning("Found sequence '"CL_WHITE" :"CL_RESET"' on line '"CL_WHITE"%u"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'. This can cause newer clients to crash.\n", lines, motd_txt);
}
}
else
{// empty line
buf[0] = ' ';
buf[1] = 0;
}
entries++;
}
fclose(fp);

ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", entries, motd_txt);
}
else
{
ShowWarning("File '"CL_WHITE"%s"CL_RESET"' not found.\n", motd_txt);
}

return 0;
}
void pc_itemcd_do(struct map_session_data *sd, bool load) {
int i,cursor = 0;
struct item_cd* cd = NULL;
Expand Down Expand Up @@ -9843,7 +9774,6 @@ int do_init_pc(void) {
itemcd_db = idb_alloc(DB_OPT_RELEASE_DATA);

pc_readdb();
pc_read_motd(); // Read MOTD [Valaris]

add_timer_func_list(pc_invincible_timer, "pc_invincible_timer");
add_timer_func_list(pc_eventtimer, "pc_eventtimer");
Expand Down
1 change: 0 additions & 1 deletion src/map/pc.h
Expand Up @@ -939,7 +939,6 @@ void pc_inventory_rentals(struct map_session_data *sd);
int pc_inventory_rental_clear(struct map_session_data *sd);
void pc_inventory_rental_add(struct map_session_data *sd, int seconds);

int pc_read_motd(void); // [Valaris]
int pc_disguise(struct map_session_data *sd, int class_);
bool pc_isautolooting(struct map_session_data *sd, int nameid);

Expand Down

0 comments on commit 9080a58

Please sign in to comment.