#include <books.h>
Public Types | |
| typedef std::vector< std::vector< std::string > > | tpages |
Public Methods | |
| void | OpenBookReadOnly (NXWSOCKET s, P_ITEM book) |
| void | OpenBookReadWrite (NXWSOCKET s, P_ITEM book) |
| Sends to the client data for opening book in read/write mode. | |
| void | SendPageReadOnly (NXWSOCKET s, P_ITEM book, UI16 p) |
| send to the specified client the page for reading only | |
| void | ChangeAuthor (char *auth) |
| Change the book author. | |
| void | ChangeTitle (char *titl) |
| Change the book title. | |
| void | ChangePages (char *packet, UI16 p, UI16 l, UI16 s) |
| parse the 0x66 package replied by client for page changes | |
| UI32 | GetIndex () const |
| < gets the book index | |
| LOGICAL | IsReadOnly () const |
| < return true if books is readonly | |
| void | GetPages (tpages &pags) const |
| < return the pages of the book | |
| std::string | GetAuthor () const |
| < return the author of the book | |
| std::string | GetTitle () const |
| < return the title of the book | |
| UI32 | GetNumPages () const |
| < return the number of pages of the book | |
Constructors and operators | |
| |
| cBook () | |
| default constructor | |
| cBook (const cBook &oldbook) | |
| Copy constructor for cBook class. | |
| cBook (P_ITEM book) | |
| item constructor | |
| cBook (std::istream &s) | |
| constructor that read the book from stream (see cBooks::ReadFrom) | |
| cBook & | operator= (const cBook &oldbook) |
| assignment operator= | |
Book Dump/Load functions | |
| |
| void | DumpTo (std::ostream &s) |
| write the book to a stream | |
| bool | ReadFrom (std::istream &s) |
| read the book from a stream | |
Private Attributes | |
| LOGICAL | readonly |
| if the book is loaded from script it must be true | |
| std::string | author |
| author of the book | |
| std::string | title |
| title of the book | |
| tpages | pages |
| pages of the book | |
| UI32 | index |
| index of the book | |
Static Private Attributes | |
| UI32 | books_index = 0 |
| 1-based books counter | |
There are two types of books, read only books, defined by scripters, in this case they are loaded from xss scripts and read/write books, wrote in game, that are saved to a save file on disk.
Two books can have the same contents if it's defined by xss script, but not if they are read/write books.
For this reason, we need to duplicate the book's data if we are duping a book item, else we could have two books "linked" together, changing one, will change the other too.
a read/write book is defined on the file like that (without tabs identation obviously :P):
SECTION RWBOOK index
{
AUTHOR author
TITLE title
PAGE
{
LINE blablabla
LINE bblalblal
}
PAGE
{
LINE blablabla
}
PAGE
{
LINE blablabla
}
}
|
|
|
|
|
default constructor
|
|
|
Copy constructor for cBook class.
|
|
|
item constructor
|
|
|
constructor that read the book from stream (see cBooks::ReadFrom)
|
|
|
Change the book author.
|
|
||||||||||||||||||||
|
parse the 0x66 package replied by client for page changes
|
|
|
Change the book title.
|
|
|
write the book to a stream
|
|
|
< return the author of the book
|
|
|
< gets the book index
|
|
|
< return the number of pages of the book
|
|
|
< return the pages of the book
|
|
|
< return the title of the book
|
|
|
< return true if books is readonly
|
|
||||||||||||
|
|
|
||||||||||||
|
Sends to the client data for opening book in read/write mode.
|
|
|
assignment operator=
|
|
|
read the book from a stream
|
|
||||||||||||||||
|
send to the specified client the page for reading only
|
|
|
author of the book
|
|
|
1-based books counter
|
|
|
index of the book
|
|
|
pages of the book
|
|
|
if the book is loaded from script it must be true
|
|
|
title of the book
|