Example #1
0
 public void sendCharacterData(Character p)
 {
     MessageOut msg=new MessageOut(Protocol.GAMSG_PLAYER_DATA);
     msg.writeInt32(p.getDatabaseID());
     p.serializeCharacterData(msg);
     send(msg);
 }
Example #2
0
 public void gotPost(Character player, string sender, string letter)
 {
     //std::map<Character*, PostCallback>::iterator itr = mCallbacks.find(player);
     //if (itr != mCallbacks.end())
     //{
     //    itr.second.handler(player, sender, letter, itr.second.data);
     //}
 }
Example #3
0
 public void addCharacter(Character player)
 {
     //std::map<int, Character*>::iterator itr = mCharacters.find(player.getDatabaseID());
     //if (itr == mCharacters.end())
     //{
     //    mCharacters.insert(std::pair<int, Character*>(player.getDatabaseID(), player));
     //}
 }
Example #4
0
        TradeState mState; /**< State of transaction. */

        #endregion Fields

        #region Constructors

        //:
        //mChar1(c1), mChar2(c2), mMoney1(0), mMoney2(0), mState(TRADE_INIT), mCurrencyId(ATTR_GP)
        /*
         * States :
         * TRADE_INIT : A player has ask to make a trade, waiting for accept
         * TRADE_RUN : Both player are now trading and can add objects and GP (1)
         * TRADE_CONFIRM_WAIT : One player has confirm, waiting for the other one
         * TRADE_CONFIRMED : Both player has confirmed and agree button is unlock (2)
         * TRADE_AGREE_WAIT : One player has agreed, waiting for the other one
         */
        Trade(Character c1, Character c2)
        {
            //MessageOut msg(GPMSG_TRADE_REQUEST);
            //msg.writeInt16(c1.getPublicID());
            //c2.getClient().send(msg);
            //c1.setTrading(this);
            //c2.setTrading(this);
        }
Example #5
0
 static void recoverQuestVar(Character ch, string name, QuestCallback f)
 {
     //    assert(ch->questCache.find(name) == ch->questCache.end());
     //    int id = ch->getDatabaseID();
     //    PendingQuests::iterator i = pendingQuests.lower_bound(id);
     //    if (i == pendingQuests.end() || i->first != id)
     //    {
     //        i = pendingQuests.insert(i, std::make_pair(id, PendingQuest()));
     //        i->second.character = ch;
     //        /* Register a listener, because we cannot afford to get invalid
     //           pointers, when we finally recover the variable. */
     //        ch->addListener(&questDeathListener);
     //    }
     //    i->second.variables[name].push_back(f);
     //    accountHandler->requestCharacterVar(ch, name);
 }
Example #6
0
        public void addPendingCharacter(string token, Character ch)
        {
            /* First, check if the character is already on the map. This may happen if
               a client just lost its connection, and logged to the account server
               again, yet the game server has not yet detected the lost connection. */

            int id=ch.getDatabaseID();

            foreach(NetComputer client in clients)
            {
                GameClient c=(GameClient)client;

                Character old_ch=c.character;
                if(old_ch!=null&&old_ch.getDatabaseID()==id)
                {
                    if(c.status!=(int)AccountClientStatus.CLIENT_CONNECTED)
                    {
                        /* Either the server is confused, or the client is up to no
                           good. So ignore the request, and wait for the connections
                           to properly time out. */
                        return;
                    }

                    /* As the connection was not properly closed, the account server
                       has not yet updated its data, so ignore them. Instead, take the
                       already present character, kill its current connection, and make
                       it available for a new connection. */

                    //delete ch;
                    GameState.remove(old_ch);
                    kill(old_ch);
                    ch=old_ch;
                    break;
                }
            }

            // Mark the character as pending a connection.
            mTokenCollector.addPendingConnect(token, ch);
        }
Example #7
0
        void addItem(Character c, int slot, int amount)
        {
            ////If the player has already confirmed, exit.
            //if ((mState != TRADE_RUN && (mState != TRADE_CONFIRM_WAIT || c != mChar1))
            //        || amount < 0) return;

            //Character *other;
            //TradedItems *items;
            //if (c == mChar1)
            //{
            //    other = mChar2;
            //    items = &mItems1;
            //}
            //else
            //{
            //    assert(c == mChar2);
            //    other = mChar1;
            //    items = &mItems2;
            //}

            //// Arbitrary limit to prevent a client from DOSing the server.
            //if (items.size() >= 50) return;

            //Inventory inv(c);
            //int id = inv.getItem(slot);
            //if (id == 0) return;

            ///* Checking now if there is enough items is useless as it can change
            //   later on. At worst, the transaction will be canceled at the end if
            //   the client lied. */

            //TradedItem ti = { id, slot, amount };
            //items.push_back(ti);

            //MessageOut msg(GPMSG_TRADE_ADD_ITEM);
            //msg.writeInt16(id);
            //msg.writeInt8(amount);
            //other.getClient().send(msg);
        }
Example #8
0
        /**
         * Sets message fields describing character look.
         */
        static void serializeLooks(Character ch, MessageOut msg, bool full)
        {
            //const Possessions &poss = ch.getPossessions();
            //unsigned int nb_slots = itemManager.getVisibleSlotCount();

            //// Bitmask describing the changed entries.
            //int changed = (1 << nb_slots) - 1;
            //if (!full)
            //{
            //    // TODO: do not assume the whole equipment changed,
            //    // when an update is asked for.
            //    changed = (1 << nb_slots) - 1;
            //}

            //std::vector<unsigned int> items;
            //items.resize(nb_slots, 0);
            //// Partially build both kinds of packet, to get their sizes.
            //unsigned int mask_full = 0, mask_diff = 0;
            //unsigned int nb_full = 0, nb_diff = 0;
            //std::map<unsigned int, unsigned int>::const_iterator it =
            //                                                poss.equipSlots.begin();
            //for (unsigned int i = 0; i < nb_slots; ++i)
            //{
            //    if (changed & (1 << i))
            //    {
            //        // Skip slots that have not changed, when sending an update.
            //        ++nb_diff;
            //        mask_diff |= 1 << i;
            //    }
            //    if (it == poss.equipSlots.end() || it.first > i) continue;
            //    ItemClass *eq;
            //    items[i] = it.first && (eq = itemManager.getItem(it.first)) ?
            //               eq.getSpriteID() : 0;
            //    if (items[i])
            //    {
            //        /* If we are sending the whole equipment, only filled slots have to
            //           be accounted for, as the other ones will be automatically cleared. */
            //        ++nb_full;
            //        mask_full |= 1 << i;
            //    }
            //}

            //// Choose the smaller payload.
            //if (nb_full <= nb_diff) full = true;

            ///* Bitmask enumerating the sent slots.
            //   Setting the upper bit tells the client to clear the slots beforehand. */
            //int mask = full ? mask_full | (1 << 7) : mask_diff;

            //msg.writeInt8(mask);
            //for (unsigned int i = 0; i < nb_slots; ++i)
            //{
            //    if (mask & (1 << i)) msg.writeInt16(items[i]);
            //}
        }
Example #9
0
        /**
         * Informs a player of what happened around the character.
         */
        static void informPlayer(MapComposite map, Character p, int worldTime)
        {
            //MessageOut moveMsg(GPMSG_BEINGS_MOVE);
            //MessageOut damageMsg(GPMSG_BEINGS_DAMAGE);
            //const Point &pold = p.getOldPosition(), ppos = p.getPosition();
            //int pid = p.getPublicID(), pflags = p.getUpdateFlags();
            //int visualRange = Configuration::getValue("game_visualRange", 448);

            //// Inform client about activities of other beings near its character
            //for (BeingIterator i(map.getAroundBeingIterator(p, visualRange)); i; ++i)
            //{
            //    Being *o = *i;

            //    const Point &oold = o.getOldPosition(), opos = o.getPosition();
            //    int otype = o.getType();
            //    int oid = o.getPublicID(), oflags = o.getUpdateFlags();
            //    int flags = 0;

            //    // Check if the character p and the moving object o are around.
            //    bool wereInRange = pold.inRangeOf(oold, visualRange) &&
            //                       !((pflags | oflags) & UPDATEFLAG_NEW_ON_MAP);
            //    bool willBeInRange = ppos.inRangeOf(opos, visualRange);

            //    if (!wereInRange && !willBeInRange)
            //    {
            //        // Nothing to report: o and p are far away from each other.
            //        continue;
            //    }

            //    if (wereInRange && willBeInRange)
            //    {
            //        // Send attack messages.
            //        if ((oflags & UPDATEFLAG_ATTACK) && oid != pid)
            //        {
            //            MessageOut AttackMsg(GPMSG_BEING_ATTACK);
            //            AttackMsg.writeInt16(oid);
            //            AttackMsg.writeInt8(o.getDirection());
            //            AttackMsg.writeInt8(static_cast< Being * >(o).getAttackId());
            //            gameHandler.sendTo(p, AttackMsg);
            //        }

            //        // Send action change messages.
            //        if ((oflags & UPDATEFLAG_ACTIONCHANGE))
            //        {
            //            MessageOut ActionMsg(GPMSG_BEING_ACTION_CHANGE);
            //            ActionMsg.writeInt16(oid);
            //            ActionMsg.writeInt8(static_cast< Being * >(o).getAction());
            //            gameHandler.sendTo(p, ActionMsg);
            //        }

            //        // Send looks change messages.
            //        if (oflags & UPDATEFLAG_LOOKSCHANGE)
            //        {
            //            MessageOut LooksMsg(GPMSG_BEING_LOOKS_CHANGE);
            //            LooksMsg.writeInt16(oid);
            //            Character * c = static_cast<Character * >(o);
            //            serializeLooks(c, LooksMsg, false);
            //            LooksMsg.writeInt16(c.getHairStyle());
            //            LooksMsg.writeInt16(c.getHairColor());
            //            LooksMsg.writeInt16(c.getGender());
            //            gameHandler.sendTo(p, LooksMsg);
            //        }

            //        // Send direction change messages.
            //        if (oflags & UPDATEFLAG_DIRCHANGE)
            //        {
            //            MessageOut DirMsg(GPMSG_BEING_DIR_CHANGE);
            //            DirMsg.writeInt16(oid);
            //            DirMsg.writeInt8(o.getDirection());
            //            gameHandler.sendTo(p, DirMsg);
            //        }

            //        // Send damage messages.
            //        if (o.canFight())
            //        {
            //            Being *victim = static_cast< Being * >(o);
            //            const Hits &hits = victim.getHitsTaken();
            //            for (Hits::const_iterator j = hits.begin(),
            //                 j_end = hits.end(); j != j_end; ++j)
            //            {
            //                damageMsg.writeInt16(oid);
            //                damageMsg.writeInt16(*j);
            //            }
            //        }

            //        if (oold == opos)
            //        {
            //            // o does not move, nothing more to report.
            //            continue;
            //        }
            //    }

            //    if (!willBeInRange)
            //    {
            //        // o is no longer visible from p. Send leave message.
            //        MessageOut leaveMsg(GPMSG_BEING_LEAVE);
            //        leaveMsg.writeInt16(oid);
            //        gameHandler.sendTo(p, leaveMsg);
            //        continue;
            //    }

            //    if (!wereInRange)
            //    {
            //        // o is now visible by p. Send enter message.
            //        MessageOut enterMsg(GPMSG_BEING_ENTER);
            //        enterMsg.writeInt8(otype);
            //        enterMsg.writeInt16(oid);
            //        enterMsg.writeInt8(static_cast< Being *>(o).getAction());
            //        enterMsg.writeInt16(opos.x);
            //        enterMsg.writeInt16(opos.y);
            //        enterMsg.writeInt8(o.getDirection());
            //        switch (otype)
            //        {
            //            case OBJECT_CHARACTER:
            //            {
            //                Character *q = static_cast< Character * >(o);
            //                enterMsg.writeString(q.getName());
            //                enterMsg.writeInt8(q.getHairStyle());
            //                enterMsg.writeInt8(q.getHairColor());
            //                enterMsg.writeInt8(q.getGender());
            //                serializeLooks(q, enterMsg, true);
            //            } break;

            //            case OBJECT_MONSTER:
            //            {
            //                Monster *q = static_cast< Monster * >(o);
            //                enterMsg.writeInt16(q.getSpecy().getId());
            //                enterMsg.writeString(q.getName());
            //            } break;

            //            case OBJECT_NPC:
            //            {
            //                NPC *q = static_cast< NPC * >(o);
            //                enterMsg.writeInt16(q.getNPC());
            //                enterMsg.writeString(q.getName());
            //            } break;

            //            default:
            //                assert(false); // TODO
            //        }
            //        gameHandler.sendTo(p, enterMsg);
            //    }

            //    if (opos != oold)
            //    {
            //        // Add position check coords every 5 seconds.
            //        if (worldTime % 50 == 0)
            //            flags |= MOVING_POSITION;

            //        flags |= MOVING_DESTINATION;
            //    }

            //    // Send move messages.
            //    moveMsg.writeInt16(oid);
            //    moveMsg.writeInt8(flags);
            //    if (flags & MOVING_POSITION)
            //    {
            //        moveMsg.writeInt16(oold.x);
            //        moveMsg.writeInt16(oold.y);
            //    }

            //    if (flags & MOVING_DESTINATION)
            //    {
            //        moveMsg.writeInt16(opos.x);
            //        moveMsg.writeInt16(opos.y);
            //        // We multiply the sent speed (in tiles per second) by ten
            //        // to get it within a byte with decimal precision.
            //        // For instance, a value of 4.5 will be sent as 45.
            //        moveMsg.writeInt8((unsigned short)
            //            (o.getModifiedAttribute(ATTR_MOVE_SPEED_TPS) * 10));
            //    }
            //}

            //// Do not send a packet if nothing happened in p's range.
            //if (moveMsg.getLength() > 2)
            //    gameHandler.sendTo(p, moveMsg);

            //if (damageMsg.getLength() > 2)
            //    gameHandler.sendTo(p, damageMsg);

            //// Inform client about status change.
            //p.sendStatus();

            //// Inform client about health change of party members
            //for (CharacterIterator i(map.getWholeMapIterator()); i; ++i)
            //{
            //    Character *c = *i;

            //    // Make sure its not the same character
            //    if (c == p)
            //        continue;

            //    // make sure they are in the same party
            //    if (c.getParty() == p.getParty())
            //    {
            //        int cflags = c.getUpdateFlags();
            //        if (cflags & UPDATEFLAG_HEALTHCHANGE)
            //        {
            //            MessageOut healthMsg(GPMSG_BEING_HEALTH_CHANGE);
            //            healthMsg.writeInt16(c.getPublicID());
            //            healthMsg.writeInt16(c.getModifiedAttribute(ATTR_HP));
            //            healthMsg.writeInt16(c.getModifiedAttribute(ATTR_MAX_HP));
            //            gameHandler.sendTo(p, healthMsg);
            //        }
            //    }
            //}

            //// Inform client about items on the ground around its character
            //MessageOut itemMsg(GPMSG_ITEMS);
            //for (FixedActorIterator i(map.getAroundBeingIterator(p, visualRange)); i;
            //                                                                        ++i)
            //{
            //    assert((*i).getType() == OBJECT_ITEM ||
            //           (*i).getType() == OBJECT_EFFECT);

            //    Actor *o = *i;
            //    Point opos = o.getPosition();
            //    int oflags = o.getUpdateFlags();
            //    bool willBeInRange = ppos.inRangeOf(opos, visualRange);
            //    bool wereInRange = pold.inRangeOf(opos, visualRange) &&
            //                       !((pflags | oflags) & UPDATEFLAG_NEW_ON_MAP);

            //    if (willBeInRange ^ wereInRange)
            //    {
            //        switch (o.getType())
            //        {
            //            case OBJECT_ITEM:
            //            {
            //                Item *o = static_cast< Item * >(*i);
            //                if (oflags & UPDATEFLAG_NEW_ON_MAP)
            //                {
            //                    /* Send a specific message to the client when an item appears
            //                       out of nowhere, so that a sound/animation can be performed. */
            //                    MessageOut appearMsg(GPMSG_ITEM_APPEAR);
            //                    appearMsg.writeInt16(o.getItemClass().getDatabaseID());
            //                    appearMsg.writeInt16(opos.x);
            //                    appearMsg.writeInt16(opos.y);
            //                    gameHandler.sendTo(p, appearMsg);
            //                }
            //                else
            //                {
            //                    itemMsg.writeInt16(willBeInRange ? o.getItemClass().getDatabaseID() : 0);
            //                    itemMsg.writeInt16(opos.x);
            //                    itemMsg.writeInt16(opos.y);
            //                }
            //            }
            //            break;
            //            case OBJECT_EFFECT:
            //            {
            //                Effect *o = static_cast< Effect * >(*i);
            //                o.show();
            //                // Don't show old effects
            //                if (!(oflags & UPDATEFLAG_NEW_ON_MAP))
            //                    break;
            //                Being *b = o.getBeing();
            //                if (b)
            //                {
            //                    MessageOut effectMsg(GPMSG_CREATE_EFFECT_BEING);
            //                    effectMsg.writeInt16(o.getEffectId());
            //                    effectMsg.writeInt16(b.getPublicID());
            //                    gameHandler.sendTo(p, effectMsg);
            //                } else {
            //                    MessageOut effectMsg(GPMSG_CREATE_EFFECT_POS);
            //                    effectMsg.writeInt16(o.getEffectId());
            //                    effectMsg.writeInt16(opos.x);
            //                    effectMsg.writeInt16(opos.y);
            //                    gameHandler.sendTo(p, effectMsg);
            //                }
            //            }
            //            break;
            //            default: break;
            //        } // Switch
            //    }
            //}

            //// Do not send a packet if nothing happened in p's range.
            //if (itemMsg.getLength() > 2)
            //    gameHandler.sendTo(p, itemMsg);
        }
Example #10
0
        void sendPost(Character c, MessageIn msg)
        {
            // send message to account server with id of sending player,
            // the id of receiving player, the letter receiver and contents, and attachments
            Logger.Write(LogLevel.Debug, "Sending GCMSG_STORE_POST.");
            MessageOut outmsg=new MessageOut(Protocol.GCMSG_STORE_POST);
            outmsg.writeInt32(c.getDatabaseID());
            outmsg.writeString(msg.readString()); // name of receiver
            outmsg.writeString(msg.readString()); // content of letter

            while(msg.getUnreadLength()>0) // attachments
            {
                // write the item id and amount for each attachment
                outmsg.writeInt32(msg.readInt16());
                outmsg.writeInt32(msg.readInt16());
            }

            send(outmsg);
        }
Example #11
0
        void getPost(Character c)
        {
            // let the postman know to expect some post for this character
            Program.postMan.addCharacter(c);

            // send message to account server with id of retrieving player
            Logger.Write(LogLevel.Debug, "Sending GCMSG_REQUEST_POST");
            MessageOut outmsg=new MessageOut(Protocol.GCMSG_REQUEST_POST);
            outmsg.writeInt32(c.getDatabaseID());
            send(outmsg);
        }
Example #12
0
 void banCharacter(Character ch, int duration)
 {
     MessageOut msg=new MessageOut(Protocol.GAMSG_BAN_PLAYER);
     msg.writeInt32(ch.getDatabaseID());
     msg.writeInt32(duration);
     send(msg);
 }
Example #13
0
        void tokenMatched(GameClient computer, Character character)
        {
            //computer.character = character;
            //computer.status = CLIENT_CONNECTED;

            //character.setClient(computer);

            //MessageOut result(GPMSG_CONNECT_RESPONSE);

            //if (!GameState::insert(character))
            //{
            //    result.writeInt8(ERRMSG_SERVER_FULL);
            //    kill(character);
            //    delete character;
            //    computer.disconnect(result);
            //    return;
            //}

            //result.writeInt8(ERRMSG_OK);
            //computer.send(result);

            //// Force sending the whole character to the client.
            //Inventory(character).sendFull();
            //character.modifiedAllAttribute();
            //std::map<int, int>::const_iterator skill_it;
            //for (skill_it = character.getSkillBegin(); skill_it != character.getSkillEnd(); skill_it++)
            //{
            //    character.updateDerivedAttributes(skill_it.first);
            //}
        }
Example #14
0
 void sendTo(Character beingPtr, MessageOut msg)
 {
     //GameClient *client = beingPtr.getClient();
     //assert(client && client.status == CLIENT_CONNECTED);
     //client.send(msg);
 }
Example #15
0
 void prepareServerChange(Character ch)
 {
     //GameClient *client = ch.getClient();
     //assert(client);
     //client.status = CLIENT_CHANGE_SERVER;
 }
Example #16
0
 void updateCharacterVar(Character ch, string name, string value)
 {
     //MessageOut msg(GAMSG_SET_VAR_CHR);
     //msg.writeInt32(ch.getDatabaseID());
     //msg.writeString(name);
     //msg.writeString(value);
     //send(msg);
 }
Example #17
0
        protected override void processMessage(MessageIn msg)
        {
            switch(msg.getId())
            {
                case Protocol.AGMSG_REGISTER_RESPONSE:
                    {
                        if(msg.readInt16()!=(short)DataVersion.DATA_VERSION_OK)
                        {
                            Logger.Write(LogLevel.Error, "Item database is outdated! Please update to prevent inconsistencies");
                            stop();   //Disconnect gracefully from account server.
                            //Stop gameserver to prevent inconsistencies.
                            System.Environment.Exit((int)ExitValue.EXIT_DB_EXCEPTION);
                        }
                        else
                        {
                            Logger.Write(LogLevel.Debug, "Local item database is in sync with account server.");
                        }

                        if(msg.readInt16()!=(short)Password.PASSWORD_OK)
                        {
                            Logger.Write(LogLevel.Error, "This game server sent a invalid password");
                            stop();
                            System.Environment.Exit((int)ExitValue.EXIT_BAD_CONFIG_PARAMETER);
                        }

                        //read world state variables
                        while(msg.getUnreadLength()>0)
                        {
                            string key=msg.readString();
                            string @value=msg.readString();

                            if(key!=""&&@value!="")
                            {
                                GameState.setVariableFromDbserver(key,  @value);
                            }
                        }

                    }
                    break;

                case Protocol.AGMSG_PLAYER_ENTER:
                    {
                        string token=msg.readString();
                        Character ptr=new Character(msg);
                        Program.gameHandler.addPendingCharacter(token, ptr);
                    }
                    break;

                case Protocol.AGMSG_ACTIVE_MAP:
                    {
                        int mapId=msg.readInt16();
                        if(MapManager.activateMap(mapId))
                        {
                            // Set map variables
                            MapComposite m=MapManager.getMap(mapId);
                            int mapVarsNumber=msg.readInt16();
                            for(int i = 0;i < mapVarsNumber;++i)
                            {
                                string key=msg.readString();
                                string @value=msg.readString();
                                if(key!=""&&@value!="")
                                {
                                    m.setVariableFromDbserver(key,  @value);
                                }
                            }

                            //Recreate potential persistent floor items
                            Logger.Write(LogLevel.Debug, "Recreate persistant items on map {0}", mapId);
                            int floorItemsNumber=msg.readInt16();

                            for(int i = 0;i < floorItemsNumber;i += 4)
                            {
                                int itemId=msg.readInt32();
                                int amount=msg.readInt16();
                                int posX=msg.readInt16();
                                int posY=msg.readInt16();

                                ItemClass ic=Program.itemManager.getItem(itemId);

                                if(ic!=null)
                                {
                                    Item item=new Item(ic, amount);
                                    item.setMap(m);
                                    Point dst=new Point(posX, posY);
                                    item.setPosition(dst);

                                    if(!GameState.insertOrDelete((Thing)item))
                                    {
                                        // The map is full.
                                        Logger.Write(LogLevel.Debug, "Couldn't add floor item(s) {0}  into map {1}", itemId, mapId);
                                        return;
                                    }
                                }
                            }
                        }

                        break;
                    }
                case Protocol.AGMSG_SET_VAR_WORLD:
                    {
                        string key=msg.readString();
                        string @value=msg.readString();
                        GameState.setVariableFromDbserver(key, value);
                        Logger.Write(LogLevel.Debug, "Global variable \"{0}\" has changed to \"{1}\"", key,  @value);
                    }
                    break;

                case Protocol.AGMSG_REDIRECT_RESPONSE:
                    {
                        int id=msg.readInt32();
                        string token=msg.readString();
                        string address=msg.readString();
                        int port=msg.readInt16();
                        Program.gameHandler.completeServerChange(id, token, address, port);
                    }
                    break;

                case Protocol.AGMSG_GET_VAR_CHR_RESPONSE:
                    {
                        int id=msg.readInt32();
                        string name=msg.readString();
                        string @value=msg.readString();
                        Quest.recoveredQuestVar(id, name,  @value);
                    }
                    break;

                case Protocol.CGMSG_CHANGED_PARTY:
                    {
                        // Character DB id
                        int charid=msg.readInt32();
                        // Party id, 0 for none
                        int partyid=msg.readInt32();
                        Program.gameHandler.updateCharacter(charid, partyid);
                    }
                    break;

                case Protocol.CGMSG_POST_RESPONSE:
                    {
                        // get the character
                        Character character=Program.postMan.getCharacter(msg.readInt32());

                        // check character is still valid
                        if(character==null)
                        {
                            break;
                        }

                        string sender=msg.readString();
                        string letter=msg.readString();

                        Program.postMan.gotPost(character, sender, letter);

                    }
                    break;

                case Protocol.CGMSG_STORE_POST_RESPONSE:
                    {
                        // get character
                        Character character=Program.postMan.getCharacter(msg.readInt32());

                        // check character is valid
                        if(character==null)
                        {
                            break;
                        }

                        //TODO: Get NPC to tell character if the sending of post
                        //was successful or not

                    }
                    break;

                default:
                    {
                        Logger.Write(LogLevel.Warning, "Invalid message type");
                        break;
                    }
            }
        }
Example #18
0
 //mCurrencyId(ATTR_GP), mChar(c), mSell(sell)
 BuySell(Character c, bool sell)
 {
     //c.setBuySell(this);
 }
Example #19
0
 void changeAccountLevel(Character c, int level)
 {
     MessageOut msg=new MessageOut(Protocol.GAMSG_CHANGE_ACCOUNT_LEVEL);
     msg.writeInt32(c.getDatabaseID());
     msg.writeInt16(level);
     send(msg);
 }
Example #20
0
 void banCharacter(Character ch, int duration)
 {
     //MessageOut msg(GAMSG_BAN_PLAYER);
     //msg.writeInt32(ch.getDatabaseID());
     //msg.writeInt32(duration);
     //send(msg);
 }
Example #21
0
 void requestCharacterVar(Character ch, string name)
 {
     MessageOut msg=new MessageOut(Protocol.GAMSG_GET_VAR_CHR);
     msg.writeInt32(ch.getDatabaseID());
     msg.writeString(name);
     send(msg);
 }
Example #22
0
 void changeAccountLevel(Character c, int level)
 {
     //MessageOut msg(GAMSG_CHANGE_ACCOUNT_LEVEL);
     //msg.writeInt32(c.getDatabaseID());
     //msg.writeInt16(level);
     //send(msg);
 }
Example #23
0
 void updateCharacterVar(Character ch, string name, string value)
 {
     MessageOut msg=new MessageOut(Protocol.GAMSG_SET_VAR_CHR);
     msg.writeInt32(ch.getDatabaseID());
     msg.writeString(name);
     msg.writeString(value);
     send(msg);
 }
Example #24
0
        void getPost(Character c)
        {
            //// let the postman know to expect some post for this character
            //postMan.addCharacter(c);

            //// send message to account server with id of retrieving player
            //LOG_DEBUG("Sending GCMSG_REQUEST_POST");
            //MessageOut out(GCMSG_REQUEST_POST);
            //out.writeInt32(c.getDatabaseID());
            //send(out);
        }
Example #25
0
 //:
 //mPoss(&p.getPossessions()), mCharacter(p)
 public Inventory(Character p)
 {
 }
Example #26
0
 void requestCharacterVar(Character ch, string name)
 {
     //MessageOut msg(GAMSG_GET_VAR_CHR);
     //msg.writeInt32(ch.getDatabaseID());
     //msg.writeString(name);
     //send(msg);
 }
Example #27
0
 public static void enqueueWarp(Character ptr, MapComposite m, int x, int y)
 {
     //TODO Implementieren
     //            DelayedEvent e=new DelayedEvent(Event.EVENT_WARP, x, y, m);
     //            enqueueEvent(ptr, e);
 }
Example #28
0
 void sendCharacterData(Character p)
 {
     //MessageOut msg(GAMSG_PLAYER_DATA);
     //msg.writeInt32(p.getDatabaseID());
     //serializeCharacterData(*p, msg);
     //send(msg);
 }
Example #29
0
        static void warp(Character ptr, MapComposite map, int x, int y)
        {
            //TODO DEBUG555 entfernen
            int debug=555;

            remove(ptr);
            ptr.setMap(map);
            ptr.setPosition(new Point(x, y));
            ptr.clearDestination();
            /* Force update of persistent data on map change, so that
               characters can respawn at the start of the map after a death or
               a disconnection. */
            Program.accountHandler.sendCharacterData(ptr);

            if(map.isActive())
            {
                if(!insert(ptr))
                {
                    ptr.disconnected();
                    Program.gameHandler.kill(ptr);
                }
            }
            else
            {
                MessageOut msg=new MessageOut(Protocol.GAMSG_REDIRECT);
                msg.writeInt32(ptr.getDatabaseID());
                Program.accountHandler.send(msg);
                Program.gameHandler.prepareServerChange(ptr);
            }
        }
Example #30
0
 void sendPost(Character c, MessageIn msg)
 {
     //// send message to account server with id of sending player,
     //// the id of receiving player, the letter receiver and contents, and attachments
     //LOG_DEBUG("Sending GCMSG_STORE_POST.");
     //MessageOut out(GCMSG_STORE_POST);
     //out.writeInt32(c.getDatabaseID());
     //out.writeString(msg.readString()); // name of receiver
     //out.writeString(msg.readString()); // content of letter
     //while (msg.getUnreadLength()) // attachments
     //{
     //    // write the item id and amount for each attachment
     //    out.writeInt32(msg.readInt16());
     //    out.writeInt32(msg.readInt16());
     //}
     //send(out);
 }