00001 /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 00002 || NoX-Wizard UO Server Emulator (NXW) [http://noxwizard.sourceforge.net] || 00003 || || 00004 || This software is free software released under GPL2 license. || 00005 || You can find detailed license information in nox-wizard.cpp file. || 00006 || || 00007 || For any question post to NoX-Wizard forums. || 00008 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ 00009 00020 #ifndef __books_h 00021 #define __books_h 00022 00023 #include <map> 00024 #include <fstream> 00025 00035 namespace Books 00036 { 00037 void LoadBooks(); 00038 void SaveBooks(); 00039 void safeoldsave(); 00040 void archive(); 00041 void addNewBook(P_ITEM book); 00042 void DoubleClickBook(NXWSOCKET s, P_ITEM book); 00043 00081 class cBook 00082 { 00083 public: 00084 typedef std::vector< std::vector<std::string> > tpages; 00085 00087 00091 cBook(); 00092 cBook(const cBook &oldbook); 00093 cBook(P_ITEM book); 00094 cBook(std::istream &s); 00095 cBook &operator = (const cBook & oldbook); 00096 00097 00099 00105 void DumpTo(std::ostream &s); 00106 bool ReadFrom(std::istream &s); 00107 00108 00109 void OpenBookReadOnly(NXWSOCKET s, P_ITEM book); 00110 void OpenBookReadWrite(NXWSOCKET s, P_ITEM book); 00111 void SendPageReadOnly(NXWSOCKET s, P_ITEM book, UI16 p); 00112 00113 void ChangeAuthor(char *auth); 00114 void ChangeTitle(char *titl); 00115 void ChangePages(char *packet, UI16 p, UI16 l, UI16 s); 00116 00117 UI32 GetIndex() const 00118 { return index; } 00119 inline LOGICAL IsReadOnly() const 00120 { return readonly; } 00121 inline void GetPages(tpages &pags) const 00122 { pags = pages; } 00123 std::string GetAuthor() const 00124 { return author; } 00125 inline std::string GetTitle() const 00126 { return title; } 00127 inline UI32 GetNumPages() const 00128 { return pages.size(); } 00129 00130 private: 00131 LOGICAL readonly; 00132 std::string author; 00133 std::string title; 00134 tpages pages; 00135 00142 UI32 index; 00143 00144 static UI32 books_index; 00145 }; 00146 00147 extern std::map<UI32, cBook> books; 00148 }; 00149 00150 #endif