Skip to content

Commit

Permalink
优化代码,DEBUG模式改为 'driver config.cfg -fdebug' 开启
Browse files Browse the repository at this point in the history
  • Loading branch information
oiuv committed Jan 31, 2019
1 parent 5557914 commit 0965d32
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 36 deletions.
45 changes: 40 additions & 5 deletions adm/single/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <config.h>
#include <localtime.h>

STATIC_VAR_TAG int DEBUG = 0;

object connect()
{
object login_ob;
Expand Down Expand Up @@ -58,7 +60,7 @@ void crash(string error, object command_giver, object current_object)
#endif
mixed cmds;
int i;

efun::shout("系统核心发出一声惨叫:哇—哩—咧—\n");
efun::shout("系统核心告诉你:要当机了,自己保重吧!\n");
log_file("static/CRASHES", MUD_NAME + " crashed on: " + ctime(time()) +
Expand All @@ -68,14 +70,14 @@ void crash(string error, object command_giver, object current_object)
log_file("static/CRASHES",
sprintf("this_player: %O\n", command_giver));
cmds = command_giver->query_commands();
for (i = 0; i < sizeof(cmds); i++)
for (i = 0; i < sizeof(cmds); i++)
{
if (cmds[i][2] == command_giver) continue;
log_file("static/CRASHES",
sprintf("%-15s %2d %O\n", cmds[i][0], cmds[i][1], cmds[i][2]));
}
if (environment(command_giver))
log_file("static/CRASHES",
log_file("static/CRASHES",
sprintf("in where: %s(%s)。\n", environment(command_giver)->query("short"),
base_name(environment(command_giver))));
log_file("static/CRASHES",
Expand Down Expand Up @@ -328,6 +330,9 @@ int valid_shadow(object ob)
{
object pre;

if(DEBUG)
write("[MASTER_OB]->valid_shadow():" + ob + "\n");

pre = previous_object();
if (geteuid(pre) == ROOT_UID ||
sscanf(file_name(pre), "/shadow/%*s"))
Expand All @@ -344,6 +349,8 @@ int valid_shadow(object ob)
// object compile-time
int valid_override( string file, string name )
{
if(DEBUG)
write("[MASTER_OB]->valid_override():" + file + "(" + name + ")\n");
// simul_efun can override any simul_efun by Annihilator
if (file == SIMUL_EFUN_OB || file == MASTER_OB)
return 1;
Expand Down Expand Up @@ -374,19 +381,25 @@ int valid_seteuid(object ob, string str)
// valid_socket: controls access to socket efunctions
int valid_socket(object eff_user, string fun, mixed *info)
{
if(DEBUG)
write("[MASTER_OB]->valid_socket():" + eff_user + "(" + fun + ")\n");
return 1;
}

// valid_asm: controls whether or not an LPC->C compiled object can use
// asm { }
int valid_asm(string file)
{
if(DEBUG)
write("[MASTER_OB]->valid_asm():" + file + "\n");
return 1;
}

// valid_compile: controls whether or not an file can be compiled
int valid_compile(string file)
{
if(DEBUG)
write("[MASTER_OB]->valid_compile():" + file + "\n");
if (! find_object(VERSION_D))
return 1;

Expand All @@ -400,6 +413,8 @@ int valid_compile(string file)
// see hidden objects
int valid_hide(object who)
{
if(DEBUG)
write("[MASTER_OB]->valid_hide():" + who + "\n");
return 1;
}

Expand All @@ -416,6 +431,8 @@ int valid_object(object ob)
// between paths
int valid_link(string original, string reference)
{
if(DEBUG)
write("[MASTER_OB]->valid_link():" + original + "-" + reference + "\n");
return 0;
}

Expand All @@ -424,11 +441,13 @@ int valid_link(string original, string reference)
// (see config file)
int valid_save_binary(string filename)
{
if(DEBUG)
write("[MASTER_OB]->valid_save_binary():" + filename + "\n");
return 1;
}

// valid_write: write privileges; called with the file name, the object
// initiating the call, and the function by which they called it.
// initiating the call, and the function by which they called it.
int valid_write(string file, mixed user, string func)
{
object ob;
Expand All @@ -444,7 +463,7 @@ int valid_write(string file, mixed user, string func)
int valid_read(string file, mixed user, string func)
{
object ob;
if (DEBUG)
if (DEBUG)
write("[MASTER_OB]->valid_read():" + file + "(" + func + ")\n");
if (ob = find_object(SECURITY_D))
return (int)ob->valid_read(file, user, func);
Expand Down Expand Up @@ -478,6 +497,11 @@ int valid_bind(object binder, object old_owner, object new_owner)
{
object ob;

if(DEBUG){
write("[MASTER_OB]->valid_bind():" + binder + "\n");
write("([old : " + old_owner + ", new : " + new_owner + "])\n");
}

if (ob = find_object(SECURITY_D))
return (int)ob->valid_bind(binder, old_owner, new_owner);

Expand Down Expand Up @@ -509,3 +533,14 @@ int direct_run_binary(string file)
// BIN代码。
return 1;
}

// driver 启动测试: -fdebug
void flag(string str) {
switch (str) {
case "debug":
DEBUG = 1;
break;
default:
write("[MASTER_OB]->flag():The only supproted flag is 'debug', got '" + str + "'.\n");
}
}
48 changes: 24 additions & 24 deletions include/command.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// command.h

#define ADM_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/app/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define ARC_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/app/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define WIZ_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/app/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define APR_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/app/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define IMM_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/app/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define PLR_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/app/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define ADM_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define ARC_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define WIZ_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define APR_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define IMM_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define PLR_PATH ({"/cmds/adm/", "/cmds/arch/", "/cmds/wiz/", "/cmds/imm/", "/cmds/usr/","/cmds/std/", "/cmds/skill/"})
#define UNR_PATH ({"/cmds/usr/", "/cmds/std/"})
#define NPC_PATH ({"/cmds/std/", "/cmds/skill/"})
#define PNE_PATH ({"/cmds/std/", "/cmds/usr/"})

// These are command objects that will also be called in those
// non-player objects.
#define ACCEPT_CMD "/cmds/std/accept"
#define DAUB_CMD "/cmds/std/daub"
#define DROP_CMD "/cmds/std/drop"
#define GET_CMD "/cmds/std/get"
#define GO_CMD "/cmds/std/go"
#define HELP_CMD "/cmds/usr/help"
#define LOOK_CMD "/cmds/std/look"
#define QUIT_CMD "/cmds/usr/quit"
#define REMOVE_CMD "/cmds/std/remove"
#define REPLY_CMD "/cmds/std/reply"
#define SKIP_CMD "/cmds/usr/skip"
#define TELL_CMD "/cmds/std/tell"
#define UPTIME_CMD "/cmds/usr/uptime"
#define WEAR_CMD "/cmds/std/wear"
#define WHO_CMD "/cmds/usr/who"
#define WIELD_CMD "/cmds/std/wield"
#define XUE_CMD "/cmds/skill/learn"
#define ACCEPT_CMD "/cmds/std/accept"
#define DAUB_CMD "/cmds/std/daub"
#define DROP_CMD "/cmds/std/drop"
#define GET_CMD "/cmds/std/get"
#define GO_CMD "/cmds/std/go"
#define HELP_CMD "/cmds/usr/help"
#define LOOK_CMD "/cmds/std/look"
#define QUIT_CMD "/cmds/usr/quit"
#define REMOVE_CMD "/cmds/std/remove"
#define REPLY_CMD "/cmds/std/reply"
#define SKIP_CMD "/cmds/usr/skip"
#define TELL_CMD "/cmds/std/tell"
#define UPTIME_CMD "/cmds/usr/uptime"
#define WEAR_CMD "/cmds/std/wear"
#define WHO_CMD "/cmds/usr/who"
#define WIELD_CMD "/cmds/std/wield"
#define XUE_CMD "/cmds/skill/learn"

// wizard command object
#define EXAMINE_CMD "/cmds/arch/examine"
#define EXAMINE_CMD "/cmds/arch/examine"
13 changes: 6 additions & 7 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

// #pragma save_binary

//mudos use this
//#define STATIC_FUNC_TAG static
//#define STATIC_VAR_TAG static

//fluffos use this
// mudos use this
// #define STATIC_FUNC_TAG static
// #define STATIC_VAR_TAG static
//
// fluffos use this
#define STATIC_FUNC_TAG private
#define STATIC_VAR_TAG nosave

#define DEBUG 0
// Important directories
#define BACKUP_DIR "/backup/"
#define COMMAND_DIR "/cmds/"
Expand Down Expand Up @@ -199,7 +198,7 @@

// Profiling switches
//
// If you changed any of these defines, you'll need reboot to make it
// If you changed any of these defines, you'll need reboot to make it
// in effect.

// Install information
Expand Down

0 comments on commit 0965d32

Please sign in to comment.