protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success= VerifyGameExists(requestCache, m_game_id, out result_code); if (success) { TypedFlags<eBindGameAction> actionFlags = LookupCharacterData(requestCache); if (actionFlags.Test(eBindGameAction.leaveGame)) { PostCharacterLeftGameEvent(requestCache); LeaveGame(requestCache); } if (actionFlags.Test(eBindGameAction.joinGame)) { PostCharacterJoinedGameEvent(requestCache); JoinGame(requestCache); } } return success; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success; if (AccountQueries.VerifyCredentials( requestCache.DatabaseContext, m_username, m_password, out m_accountId, out m_emailAddress, out m_opsLevel, out result_code)) { CharacterQueries.GetCharacterIDList(requestCache.DatabaseContext, m_accountId, out m_characterIDs); result_code= SuccessMessages.GENERAL_SUCCESS; success= true; } else { m_characterIDs = new int[] {}; success= false; } return success; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; CharacterQueries.GetCharacterPosition( requestCache.DatabaseContext, m_character_id, out m_current_room_key, out m_current_character_position, out m_current_character_angle); success = LookupCharacterGameID(requestCache, m_character_id, out m_game_id, out result_code); if (success) { success = LookupWorld(requestCache, m_game_id, out m_world, out result_code); } if (success) { success = m_world.GetRoom(requestCache.DatabaseContext, m_current_room_key, out m_room, out result_code); } if (success) { success = VerifyNavMeshConnectivity(out result_code); } if (success) { success = UpdateCharacterPosition(requestCache, out result_code); } if (success) { PostCharacterMovedEvent(requestCache); success = ComputeAIResponse(requestCache, out result_code); } if (success) { success = PingCharacter(requestCache, m_character_id, out m_result_event_list, out result_code); } return success; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { RoomTemplateSet roomTemplateSet= WorldBuilderCache.GetWorldBuilder(requestCache.DatabaseContext, requestCache.SessionCache).RoomTemplates; foreach (RoomTemplate roomTemplate in roomTemplateSet.RoomTemplateDictionary.Values) { RoomTemplateReport.AppendFormat("[{0}]\n", roomTemplate.TemplateName); roomTemplate.NavMeshTemplate.ToStringData(RoomTemplateReport); } result_code = SuccessMessages.GENERAL_SUCCESS; return true; }
private bool ClearPlayerFromCache( RequestCache requestCache, out string result_code) { bool success; if (m_character_state.game_id != -1) { World world = WorldCache.GetWorld( requestCache.DatabaseContext, requestCache.SessionCache, m_character_state.game_id); if (world != null) { requestCache.RemovePlayer( new RoomKey( m_character_state.game_id, m_character_state.room_x, m_character_state.room_y, m_character_state.room_z), m_character_id); result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.INVALID_WORLD; success = false; } } else { // Character not bound to game, thus won't be in the cache result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } return success; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { result_code = SuccessMessages.GENERAL_SUCCESS; // Get the list of games without character names gameList = GameQueries.GetGameList(requestCache.DatabaseContext); // For each game, get the character list foreach (GameResponseEntry entry in gameList) { entry.character_names= GameQueries.GetCharacterNamesInGame( requestCache.DatabaseContext, entry.game_id); } return true; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = false; result_code = SuccessMessages.GENERAL_SUCCESS; if (GameQueries.VerifyAccountOwnsGame(requestCache.DatabaseContext, m_account_id, m_game_id)) { GameQueries.DeleteGame(requestCache.DatabaseContext, m_game_id); WorldCache.ClearWorld(requestCache.SessionCache, m_game_id); success = true; } else { result_code = ErrorMessages.NOT_GAME_OWNER; } return success; }
private bool LookupCharacterGameId( RequestCache requestCache, out string result_code) { bool success; m_current_game_id = CharacterQueries.GetCharacterGameId(requestCache.DatabaseContext, m_character_id); if (m_current_game_id != -1) { result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.INVALID_GAME; success = false; } return(success); }
private bool LookupCharacterGameID( RequestCache requestCache, out string result_code) { bool success; // Get the game that the character currently belongs to m_game_id = CharacterQueries.GetCharacterGameId(requestCache.DatabaseContext, m_character_id); if (m_game_id >= 0) { result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.NOT_BOUND; success = false; } return(success); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success = LookupCharacterState(out result_code); if (success) { success = ClearPlayerFromCache(requestCache, out result_code); } if (success) { PostCharacterLeftGameEvent(requestCache); CharacterQueries.DeleteCharacter(requestCache.DatabaseContext, m_character_id); CharacterQueries.GetCharacterIDList(requestCache.DatabaseContext, m_account_id, out m_remaining_character_ids); } return success; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success = LookupWorld(requestCache, m_room_key.game_id, out m_world, out result_code); if (success) { success = LookupRoom(requestCache, out result_code); } if (success) { LookupMobs(requestCache); LookupEnergyTanks(requestCache); } return success; }
override protected bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success = LookupWorld(requestCache, m_room_key.game_id, out m_world, out result_code); if (success) { success = LookupRoom(requestCache, out result_code); } if (success) { LookupMobs(requestCache); LookupEnergyTanks(requestCache); } return(success); }
private bool UpdateEnergyTankState( RequestCache requestCache, out string result_code) { bool success = false; EnergyTank energyTank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id); if (energyTank != null) { energyTank.Energy = 0; result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.CACHE_ERROR + "(Unable to update energy tank state)"; success = false; } return(success); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; if (DetermineSpawnCount(requestCache)) { success = ChooseMobSpawners(requestCache, out result_code); if (success) { UpdateRoomRandomSeed(requestCache); SpawnMobs(requestCache); UpdateMobSpawners(requestCache); PostSpawnedMobEvents(requestCache); } } return success; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; if (DetermineSpawnCount(requestCache)) { success = ChooseMobSpawners(requestCache, out result_code); if (success) { UpdateRoomRandomSeed(requestCache); SpawnMobs(requestCache); UpdateMobSpawners(requestCache); PostSpawnedMobEvents(requestCache); } } return(success); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { int archetypeCount = EnumUtilities.GetEnumValues<GameConstants.eArchetype>().Count(); CharacterQueries.CreateCharacter( requestCache.DatabaseContext, m_account_id, m_name, m_gender, m_archetype, m_picture_id); CharacterQueries.GetCharacterIDList( requestCache.DatabaseContext, m_account_id, out m_characterIDs); result_code = SuccessMessages.GENERAL_SUCCESS; return true; }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { int archetypeCount = EnumUtilities.GetEnumValues <GameConstants.eArchetype>().Count(); CharacterQueries.CreateCharacter( requestCache.DatabaseContext, m_account_id, m_name, m_gender, m_archetype, m_picture_id); CharacterQueries.GetCharacterIDList( requestCache.DatabaseContext, m_account_id, out m_characterIDs); result_code = SuccessMessages.GENERAL_SUCCESS; return(true); }
private bool LookupOpposingPortal( RequestCache requestCache, out string result_code) { bool success; // If the opposing portal doesn't exist yet, // create a new room adjacent to the current room with an opposing portal if (m_portal.target_portal_id != -1) { //If an opposing portal exists, retrieve it from the DB m_opposing_portal = WorldQueries.GetPortal( requestCache.DatabaseContext, m_portal.target_portal_id); m_opposing_room_key = new RoomKey( m_game_id, m_opposing_portal.room_x, m_opposing_portal.room_y, m_opposing_portal.room_z); // Compute our target position in the new room // Clamp the players position into the bounding box of the portal in the new room m_opposing_portal_position = m_opposing_portal.bounding_box.ClipPoint(m_portal_position); result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.CACHE_ERROR; success = false; } return(success); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = false; result_code = SuccessMessages.GENERAL_SUCCESS; m_new_game_id = GameQueries.CreateGame( requestCache.DatabaseContext, m_account_id, m_game_name, m_dungeon_size, m_dungeon_difficulty, m_irc_enabled, m_irc_server, m_irc_port, m_irc_encryption_enabled); if (m_new_game_id >= 0) { success = WorldCache.BuildWorld( requestCache.DatabaseContext, requestCache.SessionCache, m_new_game_id, out result_code); if (!success) { GameQueries.DeleteGame(requestCache.DatabaseContext, m_new_game_id); } } return(success); }
protected static bool LookupWorld( RequestCache requestCache, int game_id, out World world, out string result_code) { bool success; // Get the room data for the room that the player is currently in world = requestCache.GetWorld(game_id); if (world != null) { result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.INVALID_WORLD; success = false; } return(success); }
private bool ChooseMobSpawners( RequestCache requestCache, out string result_code) { bool success = true; int desiredSpawnCount = m_max_spawn_count - m_current_spawn_count; result_code = SuccessMessages.GENERAL_SUCCESS; // Compute a list of all the occupied nav cells List <int> occupiedNavCells = requestCache.GetMobs(m_room.room_key).Select(m => m_room.runtime_nav_mesh.ComputeNavRefAtPoint(m.Position).NavCellIndex).ToList(); // Only use mob spawners that have a non zero remaining spawn count // and don't have a mob currently standing over stop of it. List <MobSpawner> availableMobSpawners = (from s in m_room.mobSpawners where s.RemainingSpawnCount > 0 && !occupiedNavCells.Contains(m_room.runtime_nav_mesh.ComputeNavRefAtPoint(s.Position).NavCellIndex) select s).ToList <MobSpawner>(); // Shuffle the list and pick the top N spawners (where N is based on difficulty) if (availableMobSpawners.Count > 0) { RNGUtilities.DeterministicKnuthShuffle(m_room.random_seed, availableMobSpawners); for (int spawnerIndex = 0; spawnerIndex < availableMobSpawners.Count && spawnerIndex < desiredSpawnCount; spawnerIndex++) { m_chosenMobSpawners.Add(availableMobSpawners[spawnerIndex]); } } return(success); }
private void LookupCharacterRecentEvents( RequestCache requestCache) { int new_last_game_event_id = -1; int last_game_event_id = CharacterQueries.GetCharacterLastEventId( requestCache.DatabaseContext, m_character_id); CharacterQueries.ClearCharacterNewEventFlag( requestCache.DatabaseContext, m_character_id); GameEventQueries.GetGameEventsAfterId( requestCache.DatabaseContext, m_current_game_id, last_game_event_id, out m_game_events, out new_last_game_event_id); if (m_has_new_events && new_last_game_event_id != last_game_event_id) { CharacterQueries.UpdateCharacterLastEventId( requestCache.DatabaseContext, m_character_id, new_last_game_event_id); } }
private void PostCharacterMovedEvent( RequestCache requestCache) { GameEventParameters gameEvent = new GameEvent_CharacterMoved() { character_id = m_character_id, room_x = m_current_room_key.x, room_y = m_current_room_key.y, room_z = m_current_room_key.z, from_x = m_current_character_position.x, from_y = m_current_character_position.y, from_z = m_current_character_position.z, from_angle = m_current_character_angle, to_x = m_target_position.x, to_y = m_target_position.y, to_z = m_target_position.z, to_angle = m_target_angle }; // Add a game event if the player is moving to the portal GameEventQueries.AddEvent(requestCache.DatabaseContext, m_game_id, gameEvent); m_ai_relevant_events.Add(gameEvent); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = false; result_code = SuccessMessages.GENERAL_SUCCESS; m_new_game_id = GameQueries.CreateGame( requestCache.DatabaseContext, m_account_id, m_game_name, m_dungeon_size, m_dungeon_difficulty, m_irc_enabled, m_irc_server, m_irc_port, m_irc_encryption_enabled); if (m_new_game_id >= 0) { success= WorldCache.BuildWorld( requestCache.DatabaseContext, requestCache.SessionCache, m_new_game_id, out result_code); if (!success) { GameQueries.DeleteGame(requestCache.DatabaseContext, m_new_game_id); } } return success; }
private void LookupEnergyTanks( RequestCache requestCache) { int energyTankCount = requestCache.GetEnergyTanks(m_room_key).Count(); int energyTankIndex = 0; m_energyTanks = new EnergyTankState[energyTankCount]; foreach (EnergyTank energyTank in requestCache.GetEnergyTanks(m_room_key)) { m_energyTanks[energyTankIndex] = new EnergyTankState { energy_tank_id = energyTank.ID, energy = energyTank.Energy, ownership = (int)energyTank.Faction, room_x = energyTank.RoomKey.x, room_y = energyTank.RoomKey.y, room_z = energyTank.RoomKey.z, x = energyTank.Position.x, y = energyTank.Position.y }; ++energyTankIndex; } }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success = LookupCharacterState(out result_code); if (success) { success = ClearPlayerFromCache(requestCache, out result_code); } if (success) { PostCharacterLeftGameEvent(requestCache); CharacterQueries.DeleteCharacter(requestCache.DatabaseContext, m_character_id); CharacterQueries.GetCharacterIDList(requestCache.DatabaseContext, m_account_id, out m_remaining_character_ids); } return(success); }
private bool ChooseMobSpawners( RequestCache requestCache, out string result_code) { bool success= true; int desiredSpawnCount = m_max_spawn_count - m_current_spawn_count; result_code = SuccessMessages.GENERAL_SUCCESS; // Compute a list of all the occupied nav cells List<int> occupiedNavCells = requestCache.GetMobs(m_room.room_key).Select(m => m_room.runtime_nav_mesh.ComputeNavRefAtPoint(m.Position).NavCellIndex).ToList(); // Only use mob spawners that have a non zero remaining spawn count // and don't have a mob currently standing over stop of it. List<MobSpawner> availableMobSpawners = (from s in m_room.mobSpawners where s.RemainingSpawnCount > 0 && !occupiedNavCells.Contains(m_room.runtime_nav_mesh.ComputeNavRefAtPoint(s.Position).NavCellIndex) select s).ToList<MobSpawner>(); // Shuffle the list and pick the top N spawners (where N is based on difficulty) if (availableMobSpawners.Count > 0) { RNGUtilities.DeterministicKnuthShuffle(m_room.random_seed, availableMobSpawners); for (int spawnerIndex = 0; spawnerIndex < availableMobSpawners.Count && spawnerIndex < desiredSpawnCount; spawnerIndex++) { m_chosenMobSpawners.Add(availableMobSpawners[spawnerIndex]); } } return success; }
abstract protected bool ProcessRequestInternal( RequestCache requestCache, out string result_code);
private bool LookupRoom( RequestCache requestCache, out string result_code) { m_room_key= new RoomKey(m_my_character.game_id, m_my_character.room_x, m_my_character.room_y, m_my_character.room_z); // Get the room data for the room that the player is currently in return m_world.GetRoom( requestCache.DatabaseContext, m_room_key, out m_room_world_position, out m_portals, out m_staticRoomData, out result_code); }
private void LookupGameIRCDetails( RequestCache requestCache) { // $SECURITY // Sending the IRC key unencrypted like this is not secure. // We should be encrypting it with the client's public key RSA-style. // Also we should re-generate this key any time some one removes their character from the game. // Anytime a character joins the game we should assume that they can snoop on the IRC channel. GameQueries.GetGameIRCDetails( requestCache.DatabaseContext, m_game_id, out m_irc_enabled, out m_irc_server, out m_irc_port, out m_irc_encryption_key, out m_irc_encryption_enabled); }
public bool ProcessRequest( string connection_string, ICacheAdapter sessionCache, out string result_code) { bool success = false; result_code = ErrorMessages.GENERAL_ERROR; // Remember the connection string we're using // so that request processors internal to this one // can use it as well m_connectionString = connection_string; while (!success && m_retryCount > 0) { System.Data.Common.DbTransaction dbTransaction = null; AsyncRPGDataContext dbContext = new AsyncRPGDataContext(connection_string); RequestCache requestCache = new RequestCache(sessionCache, dbContext); m_retryCount--; try { // Open the db connection immediately dbContext.Connection.Open(); // Create a transaction for the request processor. // If anything fails along the way, roll back everything. dbTransaction = dbContext.Connection.BeginTransaction(IsolationLevel.ReadCommitted); // Tell the context about the transaction so that it doesn't create one of it's own dbContext.Transaction = dbTransaction; // Start off assuming success result_code = SuccessMessages.GENERAL_SUCCESS; // Attempt to process the request if (ProcessRequestInternal( requestCache, out result_code)) { // Save any modified objects back into the DB requestCache.WriteDirtyObjectsToDatabase(); // Commit the transaction to the DB up success dbTransaction.Commit(); dbTransaction = null; success = true; } else { // Something failed (in a controlled manner) dbTransaction.Rollback(); dbTransaction = null; } } catch (System.Transactions.TransactionAbortedException ex) { // Our attempt to rollback a failed transaction failed. // Possible data corruption :( result_code = ErrorMessages.DB_ERROR + "(Transaction Aborted:" + ex.Message + ")"; success = false; // Don't bother retrying in this case m_retryCount = 0; } catch (System.Exception ex) { // An unexpected error occurred // Attempt to rollback any db changes if any were made if (dbTransaction != null) { dbTransaction.Rollback(); dbTransaction = null; } // Don't bother retrying in this case result_code = ex.Message; success = false; // Don't bother retrying in this case m_retryCount = 0; } finally { // In all cases, make sure to close the connection to the DB if (dbContext.Connection.State == ConnectionState.Open) { dbContext.Connection.Close(); } dbContext = null; } } return(success); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; CharacterQueries.GetCharacterPosition( requestCache.DatabaseContext, m_character_id, out m_current_room_key, out m_current_character_position, out m_current_character_angle); success = LookupCharacterGameID(requestCache, m_character_id, out m_game_id, out result_code); if (success) { success = LookupWorld(requestCache, m_game_id, out m_world, out result_code); } if (success) { success = m_world.GetRoom(requestCache.DatabaseContext, m_current_room_key, out m_room, out result_code); } if (success) { success = LookupPortal(out result_code); } if (success) { success = VerifyNavMeshConnectivity(out result_code); } if (success) { success = LookupOpposingPortal(requestCache, out result_code); } if (success) { success = LookupOpposingRoom(requestCache, out result_code); } if (success) { PostCharacterMovedEvent(requestCache); success = UpdateCharacterPosition(requestCache, out result_code); } if (success) { success = SpawnMobs(requestCache, out result_code); } if (success) { PostCharacterPortaledEvent(requestCache); success = PingCharacter(requestCache, m_character_id, out m_result_event_list, out result_code); } return(success); }
private void UpdateMobSpawners( RequestCache requestCache) { foreach (MobSpawner spawner in m_chosenMobSpawners) { MobQueries.UpdateMobSpawner(requestCache.DatabaseContext, spawner); } }
private void JoinGame( RequestCache requestCache) { GameQueries.BindCharacterToGame(requestCache.DatabaseContext, m_character_id, m_game_id); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; bool is_touching_energy_tank = false; result_code = SuccessMessages.GENERAL_SUCCESS; success = LookupCharacterPosition(requestCache, out result_code); if (success) { success = LookupWorld(requestCache, m_game_id, out m_world, out result_code); } if (success) { success = m_world.GetRoom(requestCache.DatabaseContext, m_current_room_key, out m_room, out result_code); } if (success) { // Goes to verifyNavMeshConnectivity if the character needs to move to reach the energy tank, // Otherwise skips to updateEnergyTankState // (Or failure if the energy tank can't be hacked) success = VerifyEnergyTank(requestCache, out is_touching_energy_tank, out result_code); } if (success && !is_touching_energy_tank) { success = VerifyNavMeshConnectivity(out result_code); if (success) { success = UpdateCharacterPosition(requestCache, out result_code); } if (success) { PostCharacterMovedEvent(requestCache); } } if (success) { success = UpdateEnergyTankState(requestCache, out result_code); } if (success) { PostEnergyTankHackedEvent(requestCache); success = ComputeAIResponse(requestCache, out result_code); } if (success) { success = PingCharacter(requestCache, m_character_id, out m_result_event_list, out result_code); } return(success); }
private bool LookupRoom( RequestCache requestCache, out string result_code) { return(m_world.GetRoom(requestCache.DatabaseContext, m_roomKey, out m_room, out result_code)); }
private void PostSpawnedMobEvents( RequestCache requestCache) { // Add a game event for every new mob foreach (Mob mob in m_newMobs) { GameEventQueries.AddEvent( requestCache.DatabaseContext, m_room.room_key.game_id, new GameEvent_MobSpawned() { mob_state = new MobState() { mob_id = mob.ID, mob_type_name = mob.MobType.Name, health = mob.Health, energy = mob.Energy, game_id = mob.RoomKey.game_id, room_x = mob.RoomKey.x, room_y = mob.RoomKey.y, room_z = mob.RoomKey.z, x = mob.Position.x, y = mob.Position.y, z = mob.Position.z, angle = mob.Angle } }); } }
private void SpawnMobs( RequestCache requestCache) { foreach (MobSpawner spawner in m_chosenMobSpawners) { Mob newMob= spawner.SpawnRandomMob(); // Locally keep track of all the mobs we created for the next steps m_newMobs.Add(newMob); } // Save the mobs into the DB MobQueries.InsertMobs(requestCache.DatabaseContext, m_room.room_key, m_newMobs); // Add the mob to the cached room data now that is has a valid mob id foreach (Mob newMob in m_newMobs) { requestCache.AddMob(newMob); } }
private void PostCharacterJoinedGameEvent( RequestCache requestCache) { // Update the character state to match the new game m_character_state.game_id = m_game_id; m_character_state.game_name = GameQueries.GetGameName(requestCache.DatabaseContext, m_game_id); // Add a note to the game event log that this new character joined the new game GameEventQueries.AddEvent( requestCache.DatabaseContext, m_game_id, new GameEvent_CharacterJoinedGame() { character_state = m_character_state }); }
private void UpdateRoomRandomSeed( RequestCache requestCache) { Random random = new Random(m_room.random_seed); m_room.random_seed = random.Next(); // Save the random seed back to the room since we just burned a seed // REVIEW: UpdateRoomRandomSeed - Not sure if this will be determinism issues if another user enters the room // around the same time since this isn't updated as a transaction WorldQueries.UpdateRoomRandomSeed( requestCache.DatabaseContext, m_room.room_key, m_room.random_seed); }
private void PostCharacterLeftGameEvent( RequestCache requestCache) { GameEventQueries.AddEvent( requestCache.DatabaseContext, m_previous_game_id, new GameEvent_CharacterLeftGame() { character_state = m_character_state }); }
protected override bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success = LookupCharacterGameID(requestCache, out result_code); if (success) { LookupGameIRCDetails(requestCache); success = LookupGameCharacterData(requestCache, out result_code); } if (success) { success = LookupWorld(requestCache, m_game_id, out m_world, out result_code); } if (success) { success = LookupRoom(requestCache, out result_code); } if (success) { LookupMobs(requestCache); LookupEnergyTanks(requestCache); success = PingCharacter(requestCache, m_character_id, out m_event_list, out result_code); } return success; }
private void LeaveGame( RequestCache requestCache) { GameQueries.UnBindCharacterFromGame(requestCache.DatabaseContext, m_character_id); }
public bool ProcessRequest( RequestCache requestCache, out string result_code) { return(ProcessRequestInternal(requestCache, out result_code)); }
private bool LookupCharacterGameID( RequestCache requestCache, out string result_code) { bool success; // Get the game that the character currently belongs to m_game_id = CharacterQueries.GetCharacterGameId(requestCache.DatabaseContext, m_character_id); if (m_game_id >= 0) { result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.NOT_BOUND; success = false; } return success; }
private bool LookupGameCharacterData( RequestCache requestCache, out string result_code) { bool success; CharacterQueries.GetGameCharacterList( requestCache.DatabaseContext, m_game_id, out m_characters); m_my_character = Array.Find(m_characters, c => c.character_id == m_character_id); success= (m_my_character != null); result_code = success ? SuccessMessages.GENERAL_SUCCESS : ErrorMessages.DB_ERROR + "(My character not associated with game)"; return success; }
private void LookupMobs( RequestCache requestCache) { int mobCount = requestCache.GetMobs(m_room_key).Count(); int mobIndex = 0; m_mobs = new MobState[mobCount]; foreach (Mob mob in requestCache.GetMobs(m_room_key)) { m_mobs[mobIndex] = new MobState { mob_id = mob.ID, mob_type_name = mob.MobType.Name, health = mob.Health, energy = mob.Energy, game_id = mob.RoomKey.game_id, room_x = mob.RoomKey.x, room_y = mob.RoomKey.y, room_z = mob.RoomKey.z, x = mob.Position.x, y = mob.Position.y, z = mob.Position.z, angle = mob.Angle }; ++mobIndex; } }
private TypedFlags<eBindGameAction> LookupCharacterData( RequestCache requestCache) { TypedFlags<eBindGameAction> actionFlags = new TypedFlags<eBindGameAction>(); actionFlags.Clear(); // Get the current state of the character before moving them to another game m_character_state = CharacterQueries.GetFullCharacterState(requestCache.DatabaseContext, m_character_id); // Get the previous game this character was a part of, if any m_previous_game_id = m_character_state.game_id; // Only bother doing anything if the character isn't already bound to this game if (m_previous_game_id != m_game_id) { if (m_previous_game_id != -1) { actionFlags.Set(eBindGameAction.leaveGame, true); } actionFlags.Set(eBindGameAction.joinGame, true); } return actionFlags; }
override protected bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; string emailVerificationString = ""; result_code = SuccessMessages.GENERAL_SUCCESS; // If the username contains any non-alphanumeric Characters, we can't accept it { Regex rgx = new Regex("[^a-zA-Z0-9]"); m_username = rgx.Replace(m_username, ""); } if (success && m_username.Length == 0) { result_code = ErrorMessages.INVALID_USERNAME; success = false; } if (success && m_password.Length == 0) { result_code = ErrorMessages.INVALID_PASSWORD; success = false; } if (success && !AsyncRPGSharedLib.Protocol.EMail.isWellFormedAddress(m_emailAddress)) { result_code = ErrorMessages.MALFORMED_EMAIL; success = false; } // Make sure the username isn't already taken if (success && !AccountQueries.VerifyUsernameAvailable(requestCache.DatabaseContext, m_username)) { result_code = ErrorMessages.RESERVED_USERNAME; success = false; } if (success) { if (MailConstants.VerifyAccountEmail) { AccountQueries.CreateAccount( requestCache.DatabaseContext, m_username, m_password, m_emailAddress, out m_emailVerificationString); if (AsyncRPGSharedLib.Protocol.EMail.SendVerifyAccountMessage( m_emailAddress, m_webServiceURL, m_username, emailVerificationString)) { result_code = SuccessMessages.GENERAL_SUCCESS + "! Sending verification e-mail to " + m_emailAddress + "."; } else { result_code = ErrorMessages.SMTP_ERROR; success = false; } } else { AccountQueries.CreateAccountNoEmailVerify( requestCache.DatabaseContext, m_username, m_password, m_emailAddress, DatabaseConstants.OpsLevel.player); result_code = SuccessMessages.GENERAL_SUCCESS + "! Account now active (email verification off)."; } } return(success); }
private bool DetermineSpawnCount( RequestCache requestCache) { m_max_spawn_count = m_world.WorldTemplate.MaxSpawnsPerRoomEntry; m_current_spawn_count = requestCache.GetMobs(m_room.room_key).Count(); return m_current_spawn_count < m_max_spawn_count; }