/* * config.h * Misc items needed to configure the mud * ____ _ * | _ \ ___ __ _| |_ __ ___ ___ * | |_) / _ \/ _` | | '_ ` _ \/ __| * | _ < __/ (_| | | | | | | \__ \ * |_| \_\___|\__,_|_|_| |_| |_|___/ * * Permission to use, modify and distribute is granted via the * Creative Commons - Attribution - Non Commercial - Share Alike 3.0 License * http://creativecommons.org/licenses/by-nc-sa/3.0/ * * Copyright (C) 2007-2009 Jason Mitchell, Randi Mitchell * Contributions by Tim Callahan, Jonathan Hseu * Based on Mordor (C) Brooke Paul, Brett J. Vickers, John P. Freeman * */ #ifndef CONFIG_H #define CONFIG_H typedef std::pair<bstring, bstring> accountDouble; class Lore; class Unique; class PlayerClass; class Skill; class GuildCreation; class Ban; class Clan; class Property; class CatRefInfo; class Ship; class QuestInfo; class Calendar; class Fishing; class SpellInfo { public: SpellInfo(); void load(xmlNodePtr rootNode); void save(xmlNodePtr rootNode) const; bool loadScript(); bstring id; bstring name; bstring file; bstring script; }; class LottoTicket { public: LottoTicket(const char* name, int pNumbers[], int pCycle); LottoTicket(xmlNodePtr rootNode); void saveToXml(xmlNodePtr rootNode); bstring owner; // Owner of this ticket short numbers[6]; // Numbers int lottoCycle; // Lottery Cycle }; class RoomSwap { public: RoomSwap(); bool moveRoom(CatRef o, CatRef t); bstring player; CatRef origin; CatRef target; }; class Config { public: static Config* getInstance(); static void destroyInstance(); // Instance private: static Config* myInstance; bool inUse; public: ~Config(); bool load(); bool save() const; void cleanUp(); // these functions deal with time and ships int currentHour(bool format=false) const; int currentMinutes() const; void resetMinutes(); void resetShipsFile(); int expectedShipUpdates() const; // Commands bool initCommands(); void clearCommands(); // Alchemy bool loadAlchemy(); bool clearAlchemy(); const AlchemyInfo *getAlchemyInfo(bstring effect) const; // Skills bool skillExists(const bstring& skillName) const; Skill* getSkill(const bstring& skillName) const; bstring getSkillGroupDisplayName(const bstring& groupName) const; bstring getSkillGroup(const bstring& skillName) const; bstring getSkillDisplayName(const bstring& skillName) const; bool isKnownOnly(const bstring& skillName) const; bool addBan(Ban* toAdd); bool deleteBan(int toDel); bool isBanned(const char *site); int isLockedOut(Socket* sock); bool guildExists(const bstring guildName); // Guilds bool addGuild(Guild* toAdd); Guild* getGuild(int guildId); Guild* getGuild(bstring name); bool deleteGuild(int guildId); // GuildCreations bstring removeGuildCreation(const bstring leaderName); GuildCreation* findGuildCreation(const bstring name); bool addGuildCreation( GuildCreation* toAdd); void creationToGuild(GuildCreation* toApprove); void guildCreationsRenameSupporter(bstring oldName, bstring newName); // Bans bool loadBans(); bool saveBans() const; void clearBanList(); // Guilds bool loadGuilds(); bool saveGuilds() const; void clearGuildList(); // Factions bool loadFactions(); void clearFactionList(); const Faction *getFaction(bstring factionStr) const; // Spells bool loadSpellList(); bool saveSpellList() const; void clearSpells(); const SpellInfo *getSpell(bstring id) const; // Fishing bool loadFishing(); void clearFishing(); const Fishing *getFishing(bstring id) const; void setFishing(bool isFishing); bool isFishing() const; // Old Quests (Quest Table) bool loadQuestTable(); void clearQuestTable(); // New Quests bool loadQuests(); void resetParentQuests(); void clearQuests(); // Areas Area *getArea(int id); bool loadAreas(); void clearAreas(); void areaInit(Creature* player, xmlNodePtr curNode); void areaInit(Creature* player, MapMarker mapmarker); void saveAreas(bool saveRooms) const; void cleanUpAreas(); // Ships bool loadShips(); void saveShips() const; void clearShips(); // Calendar void loadCalendar(); const Calendar* getCalendar() const; int classtoNum(bstring str); int racetoNum(bstring str); int deitytoNum(bstring str); int stattoNum(bstring str); int savetoNum(bstring str); const RaceData* getRace(bstring race) const; const RaceData* getRace(int id) const; const DeityData* getDeity(int id) const; // Uniques bool loadLimited(); void saveLimited() const; void clearLimited(); void addUnique(Unique* unique); void listLimited(const Player* player); void showUnique(const Player* player, int id); Unique* getUnique(const Object* object) const; Unique* getUnique(int id) const; void deleteUniques(Player* player); void deleteUnique(Unique* unique); Lore* getLore(const CatRef cr) const; void addLore(const CatRef cr, int i); void delLore(const CatRef cr); void uniqueDecay(Player* player=0); // Clans bool loadClans(); void clearClans(); const Clan *getClan(unsigned int id) const; const Clan *getClanByDeity(unsigned int deity) const; // Recipes bool loadRecipes(); void clearRecipes(); bool saveRecipes() const; Recipe *getRecipe(int id); Recipe *searchRecipes(const Player* player, bstring skill, Size recipeSize, int numIngredients, const Object* object=0); void addRecipe(Recipe* recipe); void remRecipe(Recipe* recipe); // StartLocs bool loadStartLoc(); void clearStartLoc(); const StartLoc* getStartLoc(bstring id) const; const StartLoc* getDefaultStartLoc() const; const StartLoc* getStartLocByReq(CatRef cr) const; void saveStartLocs() const; // Properties bool loadProperties(); bool saveProperties() const; void clearProperties(); void addProperty(Property* p); void showProperties(Player* viewer, Player* player, PropType propType = PROP_NONE); Property* getProperty(CatRef cr); void destroyProperty(Property *p); void destroyProperties(bstring owner); CatRef getAvailableProperty(PropType type, int numRequired); void renamePropertyOwner(bstring oldName, Player *player); Property* getProperty(const Player* player, PropType type); CatRef getSingleProperty(const Player* player, PropType type); // CatRefInfo bool loadCatRefInfo(); void clearCatRefInfo(); void saveCatRefInfo() const; const CatRefInfo* getCatRefInfo(bstring area, int id=0, int getParent=0) const; const CatRefInfo* getCatRefInfo(const BaseRoom* room, int getParent=0) const; const CatRefInfo* getRandomCatRefInfo(int zone) const; unsigned long expNeeded(int level); int getMaxSong(); // moveRoom void moveRoomLog(const bstring log, bool external=true); void moveRoom(Player* player, bstring name); void moveRoom(bstring str); void offlineMoveRoom(Server::childProcess &child, bool onReap); void offlineMoveRoom(); void findNextEmpty(Server::childProcess &child, bool onReap); CatRef findNextEmpty(bstring area); void finishMoveRoom(bstring mover); void endMoveRoom(int id=1); bool moveRoomRestrictedArea(bstring area) const; void moveRoomEmptyQueue(); void moveRoomNextInQueue(); void moveRoomAddQueue(bstring mover, CatRef origin, CatRef target); bool moveRoomInQueue(CatRef origin, bool checkTarget=false); int moveRoomQueueSize(); bool isMovingRoom() const; void setMovingRoom(CatRef o, CatRef t); void moveRoomInfo(Player* player); void moveRoomAbort(); bool checkSpecialArea(CatRef origin, CatRef target, int (CatRefInfo::*toCheck), Player* player, bool online, bstring type); bool moveRoomChecks(Player* player, CatRef origin, CatRef target); // Double Logging void addDoubleLog(bstring forum1, bstring forum2); void remDoubleLog(bstring forum1, bstring forum2); bool canDoubleLog(bstring forum1, bstring forum2) const; bool loadDoubleLog(); void saveDoubleLog() const; void listDoubleLog(const Player* viewer) const; // Misc bstring getVersion(); int getPortNum() const; void setPortNum(int pPort); bstring isAvailableSpace(Range range, int flag); bstring weatherize(WeatherString w, const BaseRoom* room) const; bstring getMonthDay() const; bool isAprilFools() const; bool willAprilFools() const; int getFlashPolicyPort() const; bool startFlashPolicy() const; bool sendTxtOnCrash() const; void toggleTxtOnCrash(); int getShopNumObjects() const; int getShopNumLines() const; // Get const cWeather* getWeather() const; bstring getDmPass() const; bstring getWebserver() const; bstring getQS() const; bstring getUserAgent() const; bstring getCustomColor(CustomColor i, bool caret) const; protected: Config(); // Can only be instantiated by itself -- Instance only void reset(); void loadGeneral(xmlNodePtr rootNode); void loadLottery(xmlNodePtr rootNode); void loadTickets(xmlNodePtr rootNode); void clearSkills(); void loadSkillGroups(xmlNodePtr rootNode); void loadSkillGroup(xmlNodePtr rootNode); void loadSkills(xmlNodePtr rootNode); void loadSkill(xmlNodePtr rootNode); public: bool loadConfig(); bool saveConfig() const; bool loadSkills(); // Player Classes bool loadClasses(); void clearClasses(); // Races bool loadRaces(); void clearRaces(); unsigned short raceCount(); unsigned short getPlayableRaceCount(); // Deities bool loadDeities(); void clearDeities(); bool loadFlags(); void clearFlags(); bool saveSpells() const; public: // Config Options bool conjureDisabled; bool lessExpLoss; bool pkillInCombatDisabled; bool autoShutdown; bool checkDouble; bool getHostByName; bool recordAll; bool logSuicide; bool charCreationDisabled; int portNum; short minBroadcastLevel; bool saveOnDrop; bool logDeath; short crashes; short supportRequiredForGuild; int numGuilds; int maxGuilds; int nextGuildId; bstring dmPass; bstring webserver; bstring qs; // authorization query string bstring userAgent; bstring defaultArea; // loaded from catrefinfo file // Lottery private: std::list<bstring> moveRoomList; std::list<RoomSwap> moveRoomQueue; std::list<LottoTicket*> tickets; bool lotteryEnabled; int lotteryCycle; long lotteryJackpot; bool lotteryWon; long lotteryWinnings; // Money made from the lottery since the last jackpot int lotteryTicketPrice; long lotteryTicketsSold; time_t lotteryRunTime; short lotteryNumbers[6]; bool movingRoom; bool roomSearchFailure; CatRef mrOrigin; CatRef mrTarget; char customColors[CUSTOM_COLOR_SIZE]; bool doAprilFools; bool txtOnCrash; int flashPolicyPort; int shopNumObjects; int shopNumLines; std::list<Unique*> uniques; std::list<Lore*> lore; std::list<accountDouble> accountDoubleLog; // Quests public: std::map<int, QuestInfo*> quests; QuestInfo* getQuest(int questNum); public: void addTicket(LottoTicket* ticket); int getCurrentLotteryCycle(); int getLotteryEnabled(); long getLotteryJackpot(); int getLotteryTicketPrice(); void increaseJackpot(int amnt); void getNumbers(short numberArray[]); void runLottery(); void setLotteryRunTime(); long getLotteryWinnings(); void winLottery(); void addLotteryWinnings(long prize); bstring getLotteryRunTimeStr(); time_t getLotteryRunTime(); int getLotteryTicketsSold(); // Misc char cmdline[256]; // Non static members public: // Alchemy std::list<AlchemyInfo*> alchemy; // Bans std::list<Ban*> bans; // Commands std::map<bstring, PlyCommand*> staffCommands; std::map<bstring, PlyCommand*> playerCommands; std::map<bstring, CrtCommand*> generalCommands; // Guilds std::list<GuildCreation*> guildCreations; std::map<int, Guild*> guilds; // Factions std::map<bstring, Faction*> factions; // Skills std::map<bstring, bstring> skillGroups; std::map<bstring, Skill*> skills; std::map<bstring, PlayerClass*> classes; std::map<bstring, StartLoc*> start; std::map<bstring, Fishing> fishing; std::map<bstring, SpellInfo> spells; std::list<Property*> properties; std::list<CatRefInfo*> catRefInfo; std::map<int, RaceData*> races; std::map<int, DeityData*> deities; std::map<int, Recipe*> recipes; std::map<int, Clan*> clans; questPtr questTable[MAX_QUEST]; std::map<int, MudFlag> rflags; std::map<int, MudFlag> xflags; std::map<int, MudFlag> pflags; std::map<int, MudFlag> mflags; std::map<int, MudFlag> oflags; std::map<int, MudFlag> specialFlags; std::map<int, MudFlag> propStorFlags; std::map<int, MudFlag> propShopFlags; std::map<int, MudFlag> propHouseFlags; std::map<int, MudFlag> propGuildFlags; bstring getSpecialFlag(int index); Calendar *calendar; std::list<Ship*> ships; std::list<Area*> areas; public: // queue related functions void flushRoom(); void flushMonster(); void flushObject(); bool monsterInQueue(const CatRef cr); void frontMonsterQueue(const CatRef cr); void addMonsterQueue(const CatRef cr, Monster** pMonster); void getMonsterQueue(const CatRef cr, Monster** pMonster); bool objectInQueue(const CatRef cr); void frontObjectQueue(const CatRef cr); void addObjectQueue(const CatRef cr, Object** pObject); void getObjectQueue(const CatRef cr, Object** pObject); bool roomInQueue(const CatRef cr); void frontRoomQueue(const CatRef cr); void addRoomQueue(const CatRef cr, Room** pRoom); void delRoomQueue(const CatRef cr); void getRoomQueue(const CatRef cr, Room** pRoom); bool reloadRoom(BaseRoom* room); int reloadRoom(CatRef cr); int resaveRoom(CatRef cr); int saveStorage(Room* uRoom); int saveStorage(CatRef cr); void resaveAllRooms(char permonly); void replaceMonsterInQueue(CatRef cr, Monster *creature); void replaceObjectInQueue(CatRef cr, Object* object); int roomQueueSize(); int monsterQueueSize(); int objectQueueSize(); void showMemory(Socket* sock); void killMortalObjects(); protected: void putQueue(qtag **qt, qtag **headptr, qtag **tailptr); void pullQueue(qtag **qt, qtag **headptr, qtag **tailptr); void frontQueue(qtag **qt, qtag **headptr, qtag **tailptr); void delQueue(qtag **qt, qtag **headptr, qtag **tailptr); // Queue header and tail pointers qtag *roomHead; qtag *roomTail; qtag *monsterHead; qtag *monsterTail; qtag *objectHead; qtag *objectTail; std::map<bstring, rsparse> roomQueue; std::map<bstring, osparse> objectQueue; std::map<bstring, msparse> monsterQueue; bool someoneFishing; }; #endif