예제 #1
0
        public static void HandleRequestCharCreate(ref PacketReader packet, ref WorldSession session)
        {
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_CharCreate);

            Player newChar = new Player(ref session);

            //newChar.GetMotionMaster()->Initialize();
            if (!newChar.Create(ObjMgr.GenerateLowGuid(HighGuidType.Player), ref packet))
            {
                // Player not create (race/class/etc problem?)
                writer.WriteUInt8((byte)ResponseCodes.CharCreateError);
                session.Send(writer);
                return;
            }

            //if ((haveSameRace && skipCinematics == 1) || skipCinematics == 2)
            //newChar.setCinematic(1);                          // not show intro

            newChar.atLoginFlags = AtLoginFlags.LoginFirst;               // First login

            // Player created, save it now
            newChar.SaveToDB(true);
            //createInfo->CharCount += 1;

            //PreparedStatement stmt = DB.Realms.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS_BY_REALM);
            //stmt->setUInt32(0, GetAccountId());
            //stmt->setUInt32(1, realmID);
            //trans->Append(stmt);

            //stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS);
            //stmt->setUInt32(0, createInfo->CharCount);
            //stmt->setUInt32(1, GetAccountId());
            //stmt->setUInt32(2, realmID);
            //trans->Append(stmt);

            // Success
            writer.WriteUInt8((byte)ResponseCodes.CharCreateSuccess);
            session.Send(writer);

            //std::string IP_str = GetRemoteAddress();
            //sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
            //sScriptMgr->OnPlayerCreate(&newChar);
            //sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
        }
예제 #2
0
            //same here
            public override bool Fallback(string[] @params = null, CommandGroup cmd = null)
            {
                if (@params == null || cmd == null || @params.Count() < 2)
                {
                    return(false);
                }

                uint objectId;

                uint.TryParse(@params[0], out objectId);

                if (objectId == 0)
                {
                    return(false);
                }

                uint spawntimeSecs;

                uint.TryParse(@params[1], out spawntimeSecs);

                GameObjectTemplate objectInfo = ObjMgr.GetGameObjectTemplate(objectId);

                if (objectInfo == null)
                {
                    cmd.SendErrorMessage(CypherStrings.GameobjectNotExist, objectId);
                    return(false);
                }

                //if (objectInfo.displayId != 0 && !DBCStorage.sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
                {
                    // report to DB errors log as in loading case
                    //sLog->outError(LOG_FILTER_SQL, "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
                    //handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
                    //return false;
                }

                Player player = cmd.GetSession().GetPlayer();
                float  x      = player.GetPositionX();
                float  y      = player.GetPositionY();
                float  z      = player.GetPositionZ();
                float  o      = player.GetOrientation();
                Map    map    = player.GetMap();

                GameObject obj     = new GameObject();
                uint       guidLow = ObjMgr.GenerateLowGuid(HighGuidType.GameObject);

                if (!obj.Create(guidLow, objectInfo.entry, map, 1 /*player.GetPhaseMgr().GetPhaseMaskForSpawn()*/, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GameObjectState.Ready))
                {
                    return(false);
                }

                //if (spawntimeSecs != 0)
                {
                    //obj.SetRespawnTime(spawntimeSecs);
                }

                // fill the gameobject data and save to the db
                obj.SaveToDB(map.GetId(), (byte)(1 << (int)map.GetSpawnMode()), 1);//player.GetPhaseMgr().GetPhaseMaskForSpawn());

                // this will generate a new guid if the object is in an instance
                if (!obj.LoadGameObjectFromDB(guidLow, map))
                {
                    return(false);
                }

                // TODO: is it really necessary to add both the real and DB table guid here ?
                ObjMgr.AddGameObjectToGrid(guidLow, ObjMgr.GetGOData(guidLow));
                cmd.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, guidLow, x, y, z);
                return(true);
            }