mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 08:18:27 +00:00
Major change to how commands are loaded
This commit is contained in:
+81
-121
@@ -73,9 +73,7 @@ extern TaskManager *taskmanager;
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
|
||||
|
||||
//struct cl_struct *commandlist; // the actual linked list of commands
|
||||
int commandcount; // how many commands we have
|
||||
int commandcount; // how many commands we have
|
||||
|
||||
// this is the pointer to the dispatch function, updated once
|
||||
// init has been performed to point at the real function
|
||||
@@ -90,7 +88,6 @@ std::map<std::string, CommandRecord *> commandlist;
|
||||
//All allocated CommandRecords get put in here so they get deleted on shutdown
|
||||
LinkedList<CommandRecord *> cleanup_commandlist;
|
||||
|
||||
|
||||
/*
|
||||
* command_notavail
|
||||
* This is the default dispatch function when commands aren't loaded.
|
||||
@@ -139,31 +136,15 @@ Access Levels:
|
||||
* Parameters:
|
||||
* none
|
||||
*
|
||||
* When adding a command, if it's the first time that function pointer is
|
||||
* used it is a new command. If that function pointer is used for another
|
||||
* command, the command is added as an alias; description and access level
|
||||
* are not used and can be nullptr.
|
||||
* When adding a new command, only hard-code 'real' commands -
|
||||
* all command aliases are added later through a database call
|
||||
*
|
||||
*/
|
||||
|
||||
int command_init(void) {
|
||||
|
||||
if
|
||||
(
|
||||
|
||||
#ifdef PACKET_PROFILER
|
||||
command_add("packetprofile", "- Dump packet profile for target or self.", 250, command_packetprofile) ||
|
||||
#endif
|
||||
#ifdef EQPROFILE
|
||||
command_add("profiledump", "- Dump profiling info to logs", 250, command_profiledump) ||
|
||||
command_add("profilereset", "- Reset profiling info", 250, command_profilereset) ||
|
||||
#endif
|
||||
#ifdef BOTS
|
||||
command_add("bot", "- Type \"#bot help\" to the see the list of available commands for bots.", 0, command_bot) ||
|
||||
#endif
|
||||
|
||||
int command_init(void)
|
||||
{
|
||||
if (
|
||||
command_add("acceptrules", "[acceptrules] - Accept the EQEmu Agreement", 0, command_acceptrules) ||
|
||||
command_add("advnpc", "analog for advnpcspawn [maketype|makegroup|addgroupentry|addgroupspawn][removegroupspawn|movespawn|editgroupbox|cleargroupbox]", 150, command_advnpcspawn) ||
|
||||
command_add("advnpcspawn", "[maketype|makegroup|addgroupentry|addgroupspawn][removegroupspawn|movespawn|editgroupbox|cleargroupbox]", 150, command_advnpcspawn) ||
|
||||
command_add("aggro", "(range) [-v] - Display aggro information for all mobs 'range' distance from your target. -v is verbose faction info.", 80, command_aggro) ||
|
||||
command_add("aggrozone", "[aggro] - Aggro every mob in the zone with X aggro. Default is 0. Not recommend if you're not invulnerable.", 100, command_aggrozone) ||
|
||||
@@ -172,27 +153,27 @@ int command_init(void) {
|
||||
command_add("apply_shared_memory", "[shared_memory_name] - Tells every zone and world to apply a specific shared memory segment by name.", 250, command_apply_shared_memory) ||
|
||||
command_add("attack", "[targetname] - Make your NPC target attack targetname", 150, command_attack) ||
|
||||
command_add("augmentitem", "Force augments an item. Must have the augment item window open.", 250, command_augmentitem) ||
|
||||
command_add("aug", nullptr, 250, command_augmentitem) ||
|
||||
command_add("ban", "[name] [reason]- Ban by character name", 150, command_ban) ||
|
||||
command_add("beard", "- Change the beard of your target", 80, command_beard) ||
|
||||
command_add("beardcolor", "- Change the beard color of your target", 80, command_beardcolor) ||
|
||||
command_add("bestz", "- Ask map for a good Z coord for your x,y coords.", 0, command_bestz) ||
|
||||
command_add("bind", "- Sets your targets bind spot to their current location", 200, command_bind) ||
|
||||
|
||||
#ifdef BOTS
|
||||
command_add("bot", "- Type \"#bot help\" to the see the list of available commands for bots.", 0, command_bot) ||
|
||||
#endif
|
||||
|
||||
command_add("camerashake", "Shakes the camera on everyone's screen globally.", 80, command_camerashake) ||
|
||||
command_add("cast", nullptr,0, command_castspell) ||
|
||||
command_add("castspell", "[spellid] - Cast a spell", 50, command_castspell) ||
|
||||
command_add("chat", "[channel num] [message] - Send a channel message to all zones", 200, command_chat) ||
|
||||
command_add("checklos", "- Check for line of sight to your target", 50, command_checklos) ||
|
||||
command_add("clearinvsnapshots", "[use rule] - Clear inventory snapshot history (true - elapsed entries, false - all entries)", 200, command_clearinvsnapshots) ||
|
||||
command_add("close_shop", nullptr, 100, command_merchantcloseshop) ||
|
||||
command_add("connectworld", nullptr,0, command_connectworldserver) ||
|
||||
command_add("connectworldserver", "- Make zone attempt to connect to worldserver", 200, command_connectworldserver) ||
|
||||
command_add("corpse", "- Manipulate corpses, use with no arguments for help", 50, command_corpse) ||
|
||||
command_add("crashtest", "- Crash the zoneserver", 255, command_crashtest) ||
|
||||
command_add("cvs", "- Summary of client versions currently online.", 200, command_cvs) ||
|
||||
command_add("crashtest", "- Crash the zoneserver", 255, command_crashtest) ||
|
||||
command_add("cvs", "- Summary of client versions currently online.", 200, command_cvs) ||
|
||||
command_add("damage", "[amount] - Damage your target", 100, command_damage) ||
|
||||
command_add("date", "[yyyy] [mm] [dd] [HH] [MM] - Set EQ time", 90, command_date) ||
|
||||
command_add("dbspawn", nullptr,10, command_npctypespawn) ||
|
||||
command_add("dbspawn2", "[spawngroup] [respawn] [variance] - Spawn an NPC from a predefined row in the spawn2 table", 100, command_dbspawn2) ||
|
||||
command_add("delacct", "[accountname] - Delete an account", 150, command_delacct) ||
|
||||
command_add("deletegraveyard", "[zone name] - Deletes the graveyard for the specified zone.", 200, command_deletegraveyard) ||
|
||||
@@ -210,8 +191,6 @@ int command_init(void) {
|
||||
command_add("enablerecipe", "[recipe_id] - Enables a recipe using the recipe id.", 80, command_enablerecipe) ||
|
||||
command_add("equipitem", "[slotid(0-21)] - Equip the item on your cursor into the specified slot", 50, command_equipitem) ||
|
||||
command_add("face", "- Change the face of your target", 80, command_face) ||
|
||||
command_add("fi", nullptr,10, command_itemsearch) ||
|
||||
command_add("finditem", nullptr,10, command_itemsearch) ||
|
||||
command_add("findnpctype", "[search criteria] - Search database NPC types", 100, command_findnpctype) ||
|
||||
command_add("findspell", "[searchstring] - Search for a spell", 50, command_findspell) ||
|
||||
command_add("findzone", "[search criteria] - Search database zones", 100, command_findzone) ||
|
||||
@@ -220,22 +199,17 @@ int command_init(void) {
|
||||
command_add("flagedit", "- Edit zone flags on your target", 100, command_flagedit) ||
|
||||
command_add("flags", "- displays the flags of you or your target", 0, command_flags) ||
|
||||
command_add("flymode", "[0/1/2] - Set your or your player target's flymode to off/on/levitate", 50, command_flymode) ||
|
||||
command_add("fn", nullptr, 100, command_findnpctype) ||
|
||||
command_add("fov", "- Check wether you're behind or in your target's field of view", 80, command_fov) ||
|
||||
command_add("freeze", "- Freeze your target", 80, command_freeze) ||
|
||||
command_add("fs", nullptr, 50, command_findspell) ||
|
||||
command_add("fz", nullptr, 100, command_findzone) ||
|
||||
command_add("gassign", "[id] - Assign targetted NPC to predefined wandering grid id", 100, command_gassign) ||
|
||||
command_add("gender", "[0/1/2] - Change your or your target's gender to male/female/neuter", 50, command_gender) ||
|
||||
command_add("getplayerburiedcorpsecount", "- Get the target's total number of buried player corpses.", 100, command_getplayerburiedcorpsecount) ||
|
||||
command_add("getvariable", "[varname] - Get the value of a variable from the database", 200, command_getvariable) ||
|
||||
command_add("gi", nullptr,200, command_giveitem) ||
|
||||
command_add("ginfo", "- get group info on target.", 20, command_ginfo) ||
|
||||
command_add("giveitem", "[itemid] [charges] - Summon an item onto your target's cursor. Charges are optional.", 200, command_giveitem) ||
|
||||
command_add("givemoney", "[pp] [gp] [sp] [cp] - Gives specified amount of money to the target player.", 200, command_givemoney) ||
|
||||
command_add("globalview", "Lists all qglobals in cache if you were to do a quest with this target.", 80, command_globalview) ||
|
||||
command_add("gm", "- Turn player target's or your GM flag on or off", 80, command_gm) ||
|
||||
command_add("gmhideme", nullptr,0, command_hideme) ||
|
||||
command_add("gmspeed", "[on/off] - Turn GM speed hack on/off for you or your player target", 100, command_gmspeed) ||
|
||||
command_add("goto", "[x] [y] [z] - Teleport to the provided coordinates or to your target", 10, command_goto) ||
|
||||
command_add("grid", "[add/delete] [grid_num] [wandertype] [pausetype] - Create/delete a wandering grid", 170, command_grid) ||
|
||||
@@ -243,7 +217,6 @@ int command_init(void) {
|
||||
command_add("guildapprove", "[guildapproveid] - Approve a guild with specified ID (guild creator receives the id)", 0, command_guildapprove) ||
|
||||
command_add("guildcreate", "[guildname] - Creates an approval setup for guild name specified", 0, command_guildcreate) ||
|
||||
command_add("guildlist", "[guildapproveid] - Lists character names who have approved the guild specified by the approve id", 0, command_guildlist) ||
|
||||
command_add("guilds", nullptr,0, command_guild) ||
|
||||
command_add("hair", "- Change the hair style of your target", 80, command_hair) ||
|
||||
command_add("haircolor", "- Change the hair color of your target", 80, command_haircolor) ||
|
||||
command_add("haste", "[percentage] - Set your haste percentage", 100, command_haste) ||
|
||||
@@ -254,7 +227,6 @@ int command_init(void) {
|
||||
command_add("heritage", "- Change the heritage of your target (Drakkin Only)", 80, command_heritage) ||
|
||||
command_add("heromodel", "[hero model] [slot] - Full set of Hero's Forge Armor appearance. If slot is set, sends exact model just to slot.", 200, command_heromodel) ||
|
||||
command_add("hideme", "[on/off] - Hide yourself from spawn lists.", 80, command_hideme) ||
|
||||
command_add("hm", "[hero model] [slot] - Full set of Hero's Forge Armor appearance. If slot is set, sends exact model just to slot.)", 200, command_heromodel) ||
|
||||
command_add("hotfix", "[hotfix_name] - Reloads shared memory into a hotfix, equiv to load_shared_memory followed by apply_shared_memory", 250, command_hotfix) ||
|
||||
command_add("hp", "- Refresh your HP bar from the server.", 0, command_hp) ||
|
||||
command_add("incstat", "- Increases or Decreases a client's stats permanently.", 200, command_incstat) ||
|
||||
@@ -262,8 +234,7 @@ int command_init(void) {
|
||||
command_add("interrogateinv", "- use [help] argument for available options", 0, command_interrogateinv) ||
|
||||
command_add("interrupt", "[message id] [color] - Interrupt your casting. Arguments are optional.", 50, command_interrupt) ||
|
||||
command_add("invsnapshot", "- Takes an inventory snapshot of your current target", 80, command_invsnapshot) ||
|
||||
command_add("invul", nullptr,0, command_invul) ||
|
||||
command_add("invulnerable", "[on/off] - Turn player target's or your invulnerable flag on or off", 80, command_invul) ||
|
||||
command_add("invul", "[on/off] - Turn player target's or your invulnerable flag on or off", 80, command_invul) ||
|
||||
command_add("ipban", "[IP address] - Ban IP by character name", 200, command_ipban) ||
|
||||
command_add("iplookup", "[charname] - Look up IP address of charname", 200, command_iplookup) ||
|
||||
command_add("iteminfo", "- Get information about the item on your cursor", 10, command_iteminfo) ||
|
||||
@@ -279,10 +250,9 @@ int command_init(void) {
|
||||
command_add("lock", "- Lock the worldserver", 150, command_lock) ||
|
||||
command_add("logs", "Manage anything to do with logs", 250, command_logs) ||
|
||||
command_add("logtest", "Performs log performance testing.", 250, command_logtest) ||
|
||||
command_add("los", nullptr,0, command_checklos) ||
|
||||
command_add("makepet", "[level] [class] [race] [texture] - Make a pet", 50, command_makepet) ||
|
||||
command_add("mana", "- Fill your or your target's mana", 50, command_mana) ||
|
||||
command_add("maxskills", "Maxes skills for you.", 200, command_max_all_skills) ||
|
||||
command_add("maxskills", "Maxes skills for you.", 200, command_max_all_skills) ||
|
||||
command_add("memspell", "[slotid] [spellid] - Memorize spellid in the specified slot", 50, command_memspell) ||
|
||||
command_add("merchant_close_shop", "Closes a merchant shop", 100, command_merchantcloseshop) ||
|
||||
command_add("merchant_open_shop", "Opens a merchants shop", 100, command_merchantopenshop) ||
|
||||
@@ -291,7 +261,7 @@ int command_init(void) {
|
||||
command_add("movechar", "[charname] [zonename] - Move charname to zonename", 50, command_movechar) ||
|
||||
command_add("myskills", "- Show details about your current skill levels", 0, command_myskills) ||
|
||||
command_add("mysqltest", "Akkadius MySQL Bench Test", 250, command_mysqltest) ||
|
||||
command_add("mysql", "Mysql CLI, see 'help' for options.", 250, command_mysql) ||
|
||||
command_add("mysql", "Mysql CLI, see 'help' for options.", 250, command_mysql) ||
|
||||
command_add("mystats", "- Show details about you or your pet", 50, command_mystats) ||
|
||||
command_add("name", "[newname] - Rename your player target", 150, command_name) ||
|
||||
command_add("netstats", "- Gets the network stats for a stream.", 200, command_netstats) ||
|
||||
@@ -302,8 +272,6 @@ int command_init(void) {
|
||||
command_add("npcsay", "[message] - Make your NPC target say a message.", 150, command_npcsay) ||
|
||||
command_add("npcshout", "[message] - Make your NPC target shout a message.", 150, command_npcshout) ||
|
||||
command_add("npcspawn", "[create/add/update/remove/delete] - Manipulate spawn DB", 170, command_npcspawn) ||
|
||||
command_add("npcspecialatk", nullptr,0, command_npcspecialattk) ||
|
||||
command_add("npcspecialattack", nullptr,0, command_npcspecialattk) ||
|
||||
command_add("npcspecialattk", "[flagchar] [perm] - Set NPC special attack flags. Flags are E(nrage) F(lurry) R(ampage) S(ummon).", 80, command_npcspecialattk) ||
|
||||
command_add("npcstats", "- Show stats about target NPC", 80, command_npcstats) ||
|
||||
command_add("npctype_cache", "[id] or all - Clears the npc type cache for either the id or all npcs.", 250, command_npctype_cache) ||
|
||||
@@ -313,7 +281,11 @@ int command_init(void) {
|
||||
command_add("object", "List|Add|Edit|Move|Rotate|Copy|Save|Undo|Delete - Manipulate static and tradeskill objects within the zone", 100, command_object) ||
|
||||
command_add("oocmute", "[1/0] - Mutes OOC chat", 200, command_oocmute) ||
|
||||
command_add("opcode", "- opcode management", 250, command_opcode) ||
|
||||
command_add("open_shop", nullptr, 100, command_merchantopenshop) ||
|
||||
|
||||
#ifdef PACKET_PROFILER
|
||||
command_add("packetprofile", "- Dump packet profile for target or self.", 250, command_packetprofile) ||
|
||||
#endif
|
||||
|
||||
command_add("path", "- view and edit pathing", 200, command_path) ||
|
||||
command_add("peekinv", "[worn/inv/cursor/trib/bank/trade/world/all] - Print out contents of your player target's inventory", 100, command_peekinv) ||
|
||||
command_add("peqzone", "[zonename] - Go to specified zone, if you have > 75% health", 0, command_peqzone) ||
|
||||
@@ -323,9 +295,15 @@ int command_init(void) {
|
||||
command_add("petitioninfo", "[petition number] - Get info about a petition", 20, command_petitioninfo) ||
|
||||
command_add("pf", "- Display additional mob coordinate and wandering data", 0, command_pf) ||
|
||||
command_add("picklock", "Analog for ldon pick lock for the newer clients since we still don't have it working.", 0, command_picklock) ||
|
||||
|
||||
#ifdef EQPROFILE
|
||||
command_add("profiledump", "- Dump profiling info to logs", 250, command_profiledump) ||
|
||||
command_add("profilereset", "- Reset profiling info", 250, command_profilereset) ||
|
||||
#endif
|
||||
|
||||
command_add("pvp", "[on/off] - Set your or your player target's PVP status", 100, command_pvp) ||
|
||||
command_add("qglobal", "[on/off/view] - Toggles qglobal functionality on an NPC", 100, command_qglobal) ||
|
||||
command_add("questerrors", "Shows quest errors.", 100, command_questerrors) ||
|
||||
command_add("questerrors", "Shows quest errors.", 100, command_questerrors) ||
|
||||
command_add("race", "[racenum] - Change your or your target's race. Use racenum 0 to return to normal", 50, command_race) ||
|
||||
command_add("raidloot", "LEADER|GROUPLEADER|SELECTED|ALL - Sets your raid loot settings if you have permission to do so.", 0, command_raidloot) ||
|
||||
command_add("randomfeatures", "- Temporarily randomizes the Facial Features of your target", 80, command_randomfeatures) ||
|
||||
@@ -333,41 +311,32 @@ int command_init(void) {
|
||||
command_add("reloadaa", "Reloads AA data", 200, command_reloadaa) ||
|
||||
command_add("reloadallrules", "Executes a reload of all rules.", 80, command_reloadallrules) ||
|
||||
command_add("reloademote", "Reloads NPC Emotes", 80, command_reloademote) ||
|
||||
command_add("reloadlevelmods", nullptr,255, command_reloadlevelmods) ||
|
||||
command_add("reloadlevelmods", nullptr, 255, command_reloadlevelmods) ||
|
||||
command_add("reloadperlexportsettings", nullptr, 255, command_reloadperlexportsettings) ||
|
||||
command_add("reloadqst", " - Clear quest cache (any argument causes it to also stop all timers)", 150, command_reloadqst) ||
|
||||
command_add("reloadquest", " - Clear quest cache (any argument causes it to also stop all timers)", 150, command_reloadqst) ||
|
||||
command_add("reloadrulesworld", "Executes a reload of all rules in world specifically.", 80, command_reloadworldrules) ||
|
||||
command_add("reloadstatic", "- Reload Static Zone Data", 150, command_reloadstatic) ||
|
||||
command_add("reloadtitles", "- Reload player titles from the database", 150, command_reloadtitles) ||
|
||||
command_add("reloadworld", "[0|1] - Clear quest cache (0 - no repop, 1 - repop)", 255, command_reloadworld) ||
|
||||
command_add("reloadzonepoints", "- Reload zone points from database", 150, command_reloadzps) ||
|
||||
command_add("reloadzps", nullptr,0, command_reloadzps) ||
|
||||
command_add("reloadzps", "- Reload zone points from database", 150, command_reloadzps) ||
|
||||
command_add("repop", "[delay] - Repop the zone with optional delay", 100, command_repop) ||
|
||||
command_add("repopclose", "[distance in units] Repops only NPC's nearby for fast development purposes", 100, command_repopclose) ||
|
||||
command_add("resetaa", "- Resets a Player's AA in their profile and refunds spent AA's to unspent, may disconnect player.", 200, command_resetaa) ||
|
||||
command_add("resetaa_timer", "Command to reset AA cooldown timers.", 200, command_resetaa_timer) ||
|
||||
command_add("revoke", "[charname] [1/0] - Makes charname unable to talk on OOC", 200, command_revoke) ||
|
||||
command_add("rq", nullptr, 150, command_reloadqst) ||
|
||||
command_add("rules", "(subcommand) - Manage server rules", 250, command_rules) ||
|
||||
command_add("rules", "(subcommand) - Manage server rules", 250, command_rules) ||
|
||||
command_add("save", "- Force your player or player corpse target to be saved to the database", 50, command_save) ||
|
||||
command_add("scribespell", "[spellid] - Scribe specified spell in your target's spell book.", 180, command_scribespell) ||
|
||||
command_add("scribespell", "[spellid] - Scribe specified spell in your target's spell book.", 180, command_scribespell) ||
|
||||
command_add("scribespells", "[max level] [min level] - Scribe all spells for you or your player target that are usable by them, up to level specified. (may freeze client for a few seconds)", 150, command_scribespells) ||
|
||||
command_add("search", nullptr,10, command_itemsearch) ||
|
||||
command_add("sendzonespawns", "- Refresh spawn list for all clients in zone", 150, command_sendzonespawns) ||
|
||||
command_add("sensetrap", "Analog for ldon sense trap for the newer clients since we still don't have it working.", 0, command_sensetrap) ||
|
||||
command_add("serverinfo", "- Get OS info about server host", 200, command_serverinfo) ||
|
||||
command_add("serverrules", "- Read this server's rules", 0, command_serverrules) ||
|
||||
command_add("setaaexp", nullptr,0, command_setaaxp) ||
|
||||
command_add("setaapoints", nullptr,0, command_setaapts) ||
|
||||
command_add("setaapts", "[value] - Set your or your player target's available AA points", 100, command_setaapts) ||
|
||||
command_add("setaaxp", "[value] - Set your or your player target's AA experience", 100, command_setaaxp) ||
|
||||
command_add("setadventurepoints", "- Set your or your player target's available adventure points", 150, command_set_adventure_points) ||
|
||||
command_add("setallskill", nullptr,0, command_setskillall) ||
|
||||
command_add("setallskills", nullptr,0, command_setskillall) ||
|
||||
command_add("setanim", "[animnum] - Set target's appearance to animnum", 200, command_setanim) ||
|
||||
command_add("setcrystals", "[value] - Set your or your player target's available radiant or ebon crystals", 100, command_setcrystals) ||
|
||||
command_add("setexp", nullptr,0, command_setxp) ||
|
||||
command_add("setfaction", "[faction number] - Sets targeted NPC's faction in the database", 170, command_setfaction) ||
|
||||
command_add("setgraveyard", "[zone name] - Creates a graveyard for the specified zone based on your target's LOC.", 200, command_setgraveyard) ||
|
||||
command_add("setlanguage", "[language ID] [value] - Set your target's language skillnum to value", 50, command_setlanguage) ||
|
||||
@@ -386,13 +355,11 @@ int command_init(void) {
|
||||
command_add("showspellslist", "Shows spell list of targeted NPC", 100, command_showspellslist) ||
|
||||
command_add("showstats", "- Show details about you or your target", 50, command_showstats) ||
|
||||
command_add("shutdown", "- Shut this zone process down", 150, command_shutdown) ||
|
||||
command_add("si", nullptr,200, command_summonitem) ||
|
||||
command_add("size", "[size] - Change size of you or your target", 50, command_size) ||
|
||||
command_add("spawn", "[name] [race] [level] [material] [hp] [gender] [class] [priweapon] [secweapon] [merchantid] - Spawn an NPC", 10, command_spawn) ||
|
||||
command_add("spawnfix", "- Find targeted NPC in database based on its X/Y/heading and update the database to make it spawn at your current location/heading.", 170, command_spawnfix) ||
|
||||
command_add("spawnstatus", "- Show respawn timer status", 100, command_spawnstatus) ||
|
||||
command_add("spellinfo", "[spellid] - Get detailed info about a spell", 10, command_spellinfo) ||
|
||||
command_add("spfind", nullptr,0, command_findspell) ||
|
||||
command_add("spoff", "- Sends OP_ManaChange", 80, command_spoff) ||
|
||||
command_add("spon", "- Sends OP_MemorizeSpell", 80, command_spon) ||
|
||||
command_add("stun", "[duration] - Stuns you or your target for duration", 100, command_stun) ||
|
||||
@@ -414,7 +381,7 @@ int command_init(void) {
|
||||
command_add("undyeme", "- Remove dye from all of your armor slots", 0, command_undyeme) ||
|
||||
command_add("unfreeze", "- Unfreeze your target", 80, command_unfreeze) ||
|
||||
command_add("unlock", "- Unlock the worldserver", 150, command_unlock) ||
|
||||
command_add("unscribespell", "[spellid] - Unscribe specified spell from your target's spell book.", 180, command_unscribespell) ||
|
||||
command_add("unscribespell", "[spellid] - Unscribe specified spell from your target's spell book.", 180, command_unscribespell) ||
|
||||
command_add("unscribespells", "- Clear out your or your player target's spell book.", 180, command_unscribespells) ||
|
||||
command_add("untraindisc", "[spellid] - Untrain specified discipline from your target.", 180, command_untraindisc) ||
|
||||
command_add("untraindiscs", "- Untrains all disciplines from your target.", 180, command_untraindiscs) ||
|
||||
@@ -446,27 +413,35 @@ int command_init(void) {
|
||||
command_add("zstats", "- Show info about zone header", 80, command_zstats) ||
|
||||
command_add("zunderworld", "[zcoord] - Sets the underworld using zcoord", 80, command_zunderworld) ||
|
||||
command_add("zuwcoords", "[z coord] - Set underworld coord", 80, command_zuwcoords)
|
||||
)
|
||||
{
|
||||
) {
|
||||
command_deinit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::map<std::string, CommandRecord *>::iterator cur,end;
|
||||
cur = commandlist.begin();
|
||||
end = commandlist.end();
|
||||
std::map<std::string,uint8> command_settings;
|
||||
std::map<std::string,uint8>::iterator itr;
|
||||
|
||||
std::map<std::string, std::pair<uint8, std::vector<std::string>>> command_settings;
|
||||
database.GetCommandSettings(command_settings);
|
||||
for(; cur != end; ++cur) {
|
||||
if ((itr=command_settings.find(cur->first))!=command_settings.end()) {
|
||||
cur->second->access = itr->second;
|
||||
Log.Out(Logs::General, Logs::Commands, "command_init(): - Command '%s' set to access level %d.", cur->first.c_str(), itr->second);
|
||||
for (std::map<std::string, CommandRecord *>::iterator iter_cl = commandlist.begin(); iter_cl != commandlist.end(); ++iter_cl) {
|
||||
std::map<std::string, std::pair<uint8, std::vector<std::string>>>::iterator iter_cs = command_settings.find(iter_cl->first);
|
||||
if (iter_cs == command_settings.end()) {
|
||||
if (iter_cl->second->access == 0)
|
||||
Log.Out(Logs::General, Logs::Commands, "command_init(): Warning: Command '%s' defaulting to access level 0!", iter_cl->first.c_str());
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cur->second->access == 0)
|
||||
Log.Out(Logs::General, Logs::Commands, "command_init(): Warning: Command '%s' defaulting to access level 0!" , cur->first.c_str());
|
||||
|
||||
iter_cl->second->access = iter_cs->second.first;
|
||||
Log.Out(Logs::General, Logs::Commands, "command_init(): - Command '%s' set to access level %d.", iter_cl->first.c_str(), iter_cs->second.first);
|
||||
if (iter_cs->second.second.empty())
|
||||
continue;
|
||||
|
||||
for (std::vector<std::string>::iterator iter_aka = iter_cs->second.second.begin(); iter_aka != iter_cs->second.second.end(); ++iter_aka) {
|
||||
if (iter_aka->empty())
|
||||
continue;
|
||||
if (commandlist.find(*iter_aka) != commandlist.end()) {
|
||||
Log.Out(Logs::General, Logs::Commands, "command_init(): Warning: Alias '%s' already exists as a command - skipping!", iter_aka->c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
commandlist[*iter_aka] = iter_cl->second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,53 +471,38 @@ void command_deinit(void)
|
||||
* adds a command to the command list; used by command_init
|
||||
*
|
||||
* Parameters:
|
||||
* command_string - the command ex: "spawn"
|
||||
* desc - text description of command for #help
|
||||
* access - default access level required to use command
|
||||
* command_name - the command ex: "spawn"
|
||||
* desc - text description of command for #help
|
||||
* access - default access level required to use command
|
||||
* function - pointer to function that handles command
|
||||
*
|
||||
*/
|
||||
int command_add(const char *command_string, const char *desc, int access, CmdFuncPtr function)
|
||||
int command_add(std::string command_name, const char *desc, int access, CmdFuncPtr function)
|
||||
{
|
||||
if(function == nullptr)
|
||||
return(-1);
|
||||
|
||||
std::string cstr(command_string);
|
||||
|
||||
if(commandlist.count(cstr) != 0) {
|
||||
Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' is a duplicate - check command.cpp." , command_string);
|
||||
return(-1);
|
||||
if (command_name.empty()) {
|
||||
Log.Out(Logs::General, Logs::Error, "command_add() - Command added with empty name string - check command.cpp.");
|
||||
return -1;
|
||||
}
|
||||
if (function == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' added without a valid function pointer - check command.cpp.", command_name.c_str());
|
||||
return -1;
|
||||
}
|
||||
if (commandlist.count(command_name) != 0) {
|
||||
Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' is a duplicate command name - check command.cpp.", command_name.c_str());
|
||||
return -1;
|
||||
}
|
||||
for (std::map<std::string, CommandRecord *>::iterator iter = commandlist.begin(); iter != commandlist.end(); ++iter) {
|
||||
if (iter->second->function != function)
|
||||
continue;
|
||||
Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' equates to an alias of '%s' - check command.cpp.", command_name.c_str(), iter->first.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
//look for aliases...
|
||||
std::map<std::string, CommandRecord *>::iterator cur,end,del;
|
||||
cur = commandlist.begin();
|
||||
end = commandlist.end();
|
||||
for(; cur != end; ++cur) {
|
||||
if(cur->second->function == function) {
|
||||
int r;
|
||||
for(r = 1; r < CMDALIASES; r++) {
|
||||
if(cur->second->command[r] == nullptr) {
|
||||
cur->second->command[r] = command_string;
|
||||
break;
|
||||
}
|
||||
}
|
||||
commandlist[cstr] = cur->second;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
CommandRecord *c = new CommandRecord;
|
||||
CommandRecord *c = new CommandRecord{ access, desc, function };
|
||||
commandlist[command_name] = c;
|
||||
cleanup_commandlist.Append(c);
|
||||
c->desc = desc;
|
||||
c->access = access;
|
||||
c->function = function;
|
||||
memset(c->command, 0, sizeof(c->command));
|
||||
c->command[0] = command_string;
|
||||
|
||||
commandlist[cstr] = c;
|
||||
|
||||
commandcount++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user