00001 /* local.cpp 00002 * 00003 * Inspired by Penn's local extensions; implemented for MUX2.4 by 00004 * M. Hassman (June 2005) 00005 */ 00006 00007 #include "copyright.h" 00008 #include "autoconf.h" 00009 #include "config.h" 00010 #include "externs.h" 00011 #include "functions.h" 00012 #include "command.h" 00013 00014 // ---------------------------------------------------------------------------- 00015 // local_funlist: List of existing functions in alphabetical order. 00016 // 00017 // Name Handler # of args min # max # flags permissions 00018 // to parse of args of args 00019 // 00020 static FUN local_funlist[] = 00021 { 00022 {NULL, NULL, MAX_ARG, 0, 0, 0, 0} 00023 }; 00024 00025 // --------------------------------------------------------------------------- 00026 // Local command tables: Definitions for local hardcode commands. 00027 // 00028 // Name Switches Permissions Key Calling Seq hook mask Handler 00029 // 00030 static CMDENT_NO_ARG local_command_table_no_arg[] = 00031 { 00032 {NULL, NULL, 0, 0, 0, 0, NULL} 00033 }; 00034 00035 static CMDENT_ONE_ARG local_command_table_one_arg[] = 00036 { 00037 {NULL, NULL, 0, 0, 0, 0, NULL} 00038 }; 00039 00040 static CMDENT_ONE_ARG_CMDARG local_command_table_one_arg_cmdarg[] = 00041 { 00042 {NULL, NULL, 0, 0, 0, 0, NULL} 00043 }; 00044 00045 static CMDENT_TWO_ARG local_command_table_two_arg[] = 00046 { 00047 {NULL, NULL, 0, 0, 0, 0, NULL} 00048 }; 00049 00050 static CMDENT_TWO_ARG_CMDARG local_command_table_two_arg_cmdarg[] = 00051 { 00052 {NULL, NULL, 0, 0, 0, 0, NULL} 00053 }; 00054 00055 static CMDENT_TWO_ARG_ARGV local_command_table_two_arg_argv[] = 00056 { 00057 {NULL, NULL, 0, 0, 0, 0, NULL} 00058 }; 00059 00060 static CMDENT_TWO_ARG_ARGV_CMDARG local_command_table_two_argv_cmdarg[] = 00061 { 00062 {NULL, NULL, 0, 0, 0, 0, NULL} 00063 }; 00064 00065 // Called after all normal MUX initialization is complete 00066 // 00067 void local_startup(void) 00068 { 00069 // Add additional hardcode functions to the above table. 00070 // 00071 functions_add(local_funlist); 00072 00073 // Add additional CMDENT_NO_ARG commands to the above table. 00074 // 00075 commands_no_arg_add(local_command_table_no_arg); 00076 commands_one_arg_add(local_command_table_one_arg); 00077 commands_one_arg_cmdarg_add(local_command_table_one_arg_cmdarg); 00078 commands_two_arg_add(local_command_table_two_arg); 00079 commands_two_arg_cmdarg_add(local_command_table_two_arg_cmdarg); 00080 commands_two_arg_argv_add(local_command_table_two_arg_argv); 00081 commands_two_arg_argv_cmdarg_add(local_command_table_two_argv_cmdarg); 00082 } 00083 00084 // This is called prior to the game syncronizing its own state to its own 00085 // database. If you depend on the the core database to store your data, you 00086 // need to checkpoint your changes here. The write-protection 00087 // mechanism in MUX is not turned on at this point. You are guaranteed 00088 // to not be a fork()-ed dumping process. 00089 // 00090 void local_presync_database(void) 00091 { 00092 } 00093 00094 // Like the above routine except that it called from the SIGSEGV handler. 00095 // At this point, your choices are limited. You can attempt to use the core 00096 // database. The core won't stop you, but it is risky. 00097 // 00098 void local_presync_database_sigsegv(void) 00099 { 00100 } 00101 00102 // This is called prior to the game database writing out it's own database. 00103 // This is typically only called from the fork()-ed process so write- 00104 // protection is in force and you will be unable to modify the game's 00105 // database for you own needs. You can however, use this point to maintain 00106 // your own dump file. 00107 // 00108 // The caveat is that it is possible the game will crash while you are doing 00109 // this, or it is already in the process of crashing. You may be called 00110 // reentrantly. Therefore, it is recommended that you follow the pattern in 00111 // dump_database_internal() and write your database to a temporary file, and 00112 // then if completed successfully, move your temporary over the top of your 00113 // old database. 00114 // 00115 // The argument dump_type is one of the 5 DUMP_I_x defines declared in 00116 // externs.h 00117 // 00118 void local_dump_database(int dump_type) 00119 { 00120 UNUSED_PARAMETER(dump_type); 00121 } 00122 00123 // The function is called when the dumping process has completed. Typically, 00124 // this will be called from within a signal handler. Your ability to do 00125 // anything interesting from within a signal handler is severly limited. 00126 // This is also called at the end of the dumping process if either no dumping 00127 // child was created or if the child finished quickly. In fact, this 00128 // may be called twice at the end of the same dump. 00129 // 00130 void local_dump_complete_signal(void) 00131 { 00132 } 00133 00134 // Called when the game is shutting down, after the game database has 00135 // been saved but prior to the logfiles being closed. 00136 // 00137 void local_shutdown(void) 00138 { 00139 } 00140 00141 // Called after the database consistency check is completed. Add 00142 // checks for local data consistency here. 00143 // 00144 void local_dbck(void) 00145 { 00146 } 00147 00148 // Called when a player connects or creates at the connection screen. 00149 // isnew of 1 indicates it was a creation, 0 is for a connection. 00150 // num indicates the number of current connections for player. 00151 // 00152 void local_connect(dbref player, int isnew, int num) 00153 { 00154 UNUSED_PARAMETER(player); 00155 UNUSED_PARAMETER(isnew); 00156 UNUSED_PARAMETER(num); 00157 } 00158 00159 // Called when player disconnects from the game. The parameter 'num' is 00160 // the number of connections the player had upon being disconnected. 00161 // Any value greater than 1 indicates multiple connections. 00162 // 00163 void local_disconnect(dbref player, int num) 00164 { 00165 UNUSED_PARAMETER(player); 00166 UNUSED_PARAMETER(num); 00167 } 00168 00169 // Called after any object type is created. 00170 // 00171 void local_data_create(dbref object) 00172 { 00173 UNUSED_PARAMETER(object); 00174 } 00175 00176 // Called when an object is cloned. clone is the new object created 00177 // from source. 00178 // 00179 void local_data_clone(dbref clone, dbref source) 00180 { 00181 UNUSED_PARAMETER(clone); 00182 UNUSED_PARAMETER(source); 00183 } 00184 00185 // Called when the object is truly destroyed, not just set GOING 00186 // 00187 void local_data_free(dbref object) 00188 { 00189 UNUSED_PARAMETER(object); 00190 }