Dragonfly 4.21
A text-based game engine
|
Public Member Functions | |
virtual int | eventHandler (const Event *p_e) override |
virtual int | handleData (const EventNetwork *p_e) |
int | sendMessage (MessageType msg_type, int sock=-1) |
int | sendMessage (MessageType msg_type, Object *p_obj, unsigned int attr=0, int sock=-1) |
int | sendMessage (MessageType msg_type, EventKeyboardAction action, Keyboard::Key key, int sock=-1) |
int | sendMessage (MessageType msg_type, EventMouseAction action, Mouse::Button button, Vector mouse_position, int sock=-1) |
int | sendMessage (MessageType msg_type, int num_bytes, const void *bytes, int sock=-1) |
int | genDataEvents (int sock=0) const |
virtual Object * | createObject (std::string object_type) |
Public Member Functions inherited from df::Object | |
Object () | |
virtual | ~Object () |
void | setId (int new_id) |
int | getId () const |
virtual void | setType (std::string new_type) |
std::string | getType () const |
virtual int | setPosition (Vector new_position) |
Vector | getPosition () const |
virtual int | eventHandler (const Event *p_event) |
bool | isSolid () const |
virtual int | setSolidness (Solidness new_solid) |
Solidness | getSolidness () const |
void | setNoSoft (bool new_no_soft=true) |
bool | getNoSoft () const |
virtual void | setAvoidCollisions (bool new_avoid_collisions=true) |
bool | getAvoidCollisions () const |
virtual int | setAltitude (int new_altitude) |
int | getAltitude () const |
void | setSpeed (float speed) |
float | getSpeed () const |
virtual void | setDirection (Vector new_direction) |
Vector | getDirection () const |
virtual void | setVelocity (Vector velocity) |
Vector | getVelocity () const |
virtual void | setAcceleration (Vector new_acceleration) |
Vector | getAcceleration () const |
void | accelerate () |
Vector | predictPosition () |
void | pathTo (Vector position) |
void | pathTo (Object *p_o_target) |
void | moveTo (Vector new_position) |
void | doPathFollowing () |
int | setVisible (bool new_visible=true) |
virtual bool | isVisible () const |
virtual int | setActive (bool new_active=true) |
bool | isActive () const |
virtual void | setBox (Box new_box) |
Box | getBox () const |
int | registerInterest (std::string event_type) |
int | unregisterInterest (std::string event_type) |
int | getEventCount () const |
virtual int | setSprite (std::string sprite_label) |
virtual void | setAnimation (Animation new_animation, bool set_box=true) |
Animation | getAnimation () const |
virtual int | draw () |
virtual int | serialize (std::stringstream *p_ss, unsigned int attr=0) |
virtual int | deserialize (std::stringstream *p_ss, unsigned int *p_a=NULL) |
bool | isModified (enum ObjectAttribute attribute) const |
bool | isModified () const |
virtual void | setModified (unsigned int new_modified) |
virtual unsigned int | getModified () const |
virtual void | setShape (Shape new_shape) |
Shape | getShape () const |
virtual void | setFollowPath (bool new_follow_path=true) |
bool | getFollowPath () const |
void | setPath (Path new_path) |
Path | getPath () const |
PathFind * | getPathFind () |
std::string | toString () const |
bool | operator== (const Object &o) |
bool | operator!= (const Object &o) |
Protected Attributes | |
char * | m_p_buff |
int | m_buff_size |
Private Member Functions | |
int | sizeBuffer (int msg_size) |
int | prepMessageHeader (MessageType msg_type, int msg_size) |
Additional Inherited Members | |
Static Public Attributes inherited from df::Object | |
static int | max_id |
|
virtual |
|
overridevirtual |
Handle network and step events.
Step events: call genDataEvents(). Network events: if type DATA, call handleData(). Return 1 if handled, else 0 if ignored.
Reimplemented from df::Object.
int df::NetworkNode::genDataEvents | ( | int | sock = 0 | ) | const |
Called each step to generate data events, when appropriate.
If complete network message, (first int is message size, in bytes) generate EventNetwork (DATA). Return 1 if generated event, 0 if no message complete message, -1 if error.
|
virtual |
Handle and generate events based on type.
GAME_OVER: generate game over network event. DELETE: markForDelete() and generate delete network event. SYNC: create if needed, then deserialize and generate sync network event. KEYBOARD: generate send keyboard network event. MOUSE: generate send mouse network event. CUSTOM: generate custom network event. Return 1 if handled, else 0 if ignored.
|
private |
Prepare message buffer and header.
Return 0 if ok, else -1 if error.
int df::NetworkNode::sendMessage | ( | MessageType | msg_type, |
EventKeyboardAction | action, | ||
Keyboard::Key | key, | ||
int | sock = -1 |
||
) |
Send message from Client to Server.
KEYBOARD_INPUT Return 1 if something sent, 0 if nothing sent, -1 if error.
int df::NetworkNode::sendMessage | ( | MessageType | msg_type, |
EventMouseAction | action, | ||
Mouse::Button | button, | ||
Vector | mouse_position, | ||
int | sock = -1 |
||
) |
Send message from Client to Server.
MOUSE_INPUT Return 1 if something sent, 0 if nothing sent, -1 if error.
int df::NetworkNode::sendMessage | ( | MessageType | msg_type, |
int | num_bytes, | ||
const void * | bytes, | ||
int | sock = -1 |
||
) |
Send message from either Client to Server or Server to Client.
CUSTOM_MESSAGE Return 1 if something sent, 0 if nothing sent, -1 if error.
int df::NetworkNode::sendMessage | ( | MessageType | msg_type, |
int | sock = -1 |
||
) |
Send message (supporting various message types).
Send message from Server to Client. SET_GAME_OVER Return 1 if something sent, 0 if nothing sent, -1 if error.
int df::NetworkNode::sendMessage | ( | MessageType | msg_type, |
Object * | p_obj, | ||
unsigned int | attr = 0 , |
||
int | sock = -1 |
||
) |
Send message from Server to Client.
SYNC_OBJECT or DELETE_OBJECT Synchronize attr, passed to serialize() (default is sync all). Return 1 if something sent, 0 if nothing sent, -1 if error.
|
private |
Increase size of network message buffer (if needed).
Return 0 if ok, else -1 if error.