00001 /* 00002 * The Mana World 00003 * Copyright (C) 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #include "player.h" 00023 00024 #include "internal.h" 00025 00026 #include "net/tmwserv/connection.h" 00027 #include "net/tmwserv/protocol.h" 00028 00029 #include "net/messageout.h" 00030 00031 void RespawnRequestListener::action(const gcn::ActionEvent &event) 00032 { 00033 Net::GameServer::Player::respawn(); 00034 } 00035 00036 void Net::GameServer::Player::walk(int x, int y) 00037 { 00038 MessageOut msg(PGMSG_WALK); 00039 msg.writeInt16(x); 00040 msg.writeInt16(y); 00041 Net::GameServer::connection->send(msg); 00042 } 00043 00044 void Net::GameServer::Player::pickUp(int x, int y) 00045 { 00046 MessageOut msg(PGMSG_PICKUP); 00047 msg.writeInt16(x); 00048 msg.writeInt16(y); 00049 Net::GameServer::connection->send(msg); 00050 } 00051 00052 void Net::GameServer::Player::moveItem(int oldSlot, int newSlot, int amount) 00053 { 00054 MessageOut msg(PGMSG_MOVE_ITEM); 00055 msg.writeInt8(oldSlot); 00056 msg.writeInt8(newSlot); 00057 msg.writeInt8(amount); 00058 Net::GameServer::connection->send(msg); 00059 } 00060 00061 void Net::GameServer::Player::attack(int direction) 00062 { 00063 MessageOut msg(PGMSG_ATTACK); 00064 msg.writeInt8(direction); 00065 Net::GameServer::connection->send(msg); 00066 } 00067 00068 void Net::GameServer::Player::useSpecial(int special) 00069 { 00070 MessageOut msg(PGMSG_USE_SPECIAL); 00071 msg.writeInt8(special); 00072 Net::GameServer::connection->send(msg); 00073 } 00074 00075 void Net::GameServer::Player::requestTrade(int id) 00076 { 00077 MessageOut msg(PGMSG_TRADE_REQUEST); 00078 msg.writeInt16(id); 00079 Net::GameServer::connection->send(msg); 00080 } 00081 00082 void Net::GameServer::Player::acceptTrade(bool accept) 00083 { 00084 MessageOut msg(accept ? PGMSG_TRADE_REQUEST : PGMSG_TRADE_CANCEL); 00085 Net::GameServer::connection->send(msg); 00086 } 00087 00088 void Net::GameServer::Player::tradeMoney(int amount) 00089 { 00090 MessageOut msg(PGMSG_TRADE_SET_MONEY); 00091 msg.writeInt32(amount); 00092 Net::GameServer::connection->send(msg); 00093 } 00094 00095 void Net::GameServer::Player::raiseAttribute(int attribute) 00096 { 00097 MessageOut msg(PGMSG_RAISE_ATTRIBUTE); 00098 msg.writeInt8(attribute); 00099 Net::GameServer::connection->send(msg); 00100 } 00101 00102 void Net::GameServer::Player::lowerAttribute(int attribute) 00103 { 00104 MessageOut msg(PGMSG_LOWER_ATTRIBUTE); 00105 msg.writeInt8(attribute); 00106 Net::GameServer::connection->send(msg); 00107 } 00108 00109 void Net::GameServer::Player::respawn() 00110 { 00111 MessageOut msg(PGMSG_RESPAWN); 00112 Net::GameServer::connection->send(msg); 00113 }