From 75392297b52354cb97e09d3f835f4271973eb7b6 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 5 Feb 2017 19:01:06 +0200 Subject: [PATCH] [General] Use vector::at in most places --- apps/openmw/mwmp/LocalEvent.cpp | 32 +++++++++---------- apps/openmw/mwmp/LocalPlayer.cpp | 6 ++-- .../Packets/Player/PacketPlayerCellState.cpp | 2 +- .../Packets/Player/PacketPlayerInventory.cpp | 2 +- .../Packets/Player/PacketPlayerJournal.cpp | 2 +- .../Packets/Player/PacketPlayerSpellbook.cpp | 2 +- .../Packets/World/PacketContainer.cpp | 4 +-- .../Packets/World/PacketDoorState.cpp | 2 +- .../Packets/World/PacketMusicPlay.cpp | 2 +- .../Packets/World/PacketObjectAnimPlay.cpp | 2 +- .../Packets/World/PacketObjectDelete.cpp | 2 +- .../Packets/World/PacketObjectLock.cpp | 2 +- .../Packets/World/PacketObjectMove.cpp | 2 +- .../Packets/World/PacketObjectPlace.cpp | 2 +- .../Packets/World/PacketObjectRotate.cpp | 2 +- .../Packets/World/PacketObjectScale.cpp | 2 +- .../Packets/World/PacketObjectUnlock.cpp | 2 +- .../Packets/World/PacketScriptGlobalShort.cpp | 2 +- .../Packets/World/PacketScriptLocalFloat.cpp | 2 +- .../Packets/World/PacketScriptLocalShort.cpp | 2 +- .../Packets/World/PacketScriptMemberShort.cpp | 2 +- .../Packets/World/PacketVideoPlay.cpp | 2 +- 22 files changed, 40 insertions(+), 40 deletions(-) diff --git a/apps/openmw/mwmp/LocalEvent.cpp b/apps/openmw/mwmp/LocalEvent.cpp index 8cb1577bf..e03bd4d18 100644 --- a/apps/openmw/mwmp/LocalEvent.cpp +++ b/apps/openmw/mwmp/LocalEvent.cpp @@ -51,7 +51,7 @@ void LocalEvent::editContainer(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -100,7 +100,7 @@ void LocalEvent::placeObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s\n- charge: %i\n- count: %i", worldObject.refId.c_str(), @@ -138,7 +138,7 @@ void LocalEvent::deleteObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -164,7 +164,7 @@ void LocalEvent::lockObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -190,7 +190,7 @@ void LocalEvent::unlockObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -216,7 +216,7 @@ void LocalEvent::scaleObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -242,7 +242,7 @@ void LocalEvent::moveObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -269,7 +269,7 @@ void LocalEvent::rotateObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -296,7 +296,7 @@ void LocalEvent::animateObjects(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -323,7 +323,7 @@ void LocalEvent::activateDoors(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", worldObject.refId.c_str(), @@ -350,7 +350,7 @@ void LocalEvent::playMusic() for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- filename: %s", worldObject.filename.c_str()); @@ -365,7 +365,7 @@ void LocalEvent::playVideo() for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- filename: %s\n- allowSkipping: %s", worldObject.filename.c_str(), @@ -381,7 +381,7 @@ void LocalEvent::setLocalShorts(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i", worldObject.refId.c_str(), @@ -409,7 +409,7 @@ void LocalEvent::setLocalFloats(MWWorld::CellStore* cellStore) for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f", worldObject.refId.c_str(), @@ -437,7 +437,7 @@ void LocalEvent::setMemberShorts() for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- cellRef: %s\n- index: %i\n- shortVal: %i\n", worldObject.refId.c_str(), @@ -469,7 +469,7 @@ void LocalEvent::setGlobalShorts() for (unsigned int i = 0; i < objectChanges.count; i++) { - worldObject = objectChanges.objects[i]; + worldObject = objectChanges.objects.at(i); LOG_APPEND(Log::LOG_WARN, "- varName: %s\n- shortVal: %i", worldObject.varName.c_str(), diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 753e98ba1..880dc232b 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -636,7 +636,7 @@ void LocalPlayer::addItems() for (unsigned int i = 0; i < inventoryChanges.count; i++) { - mwmp::Item item = inventoryChanges.items[i]; + mwmp::Item item = inventoryChanges.items.at(i); MWWorld::Ptr itemPtr = *ptrStore.add(item.refId, item.count, ptrPlayer); if (item.charge != -1) itemPtr.getCellRef().setCharge(item.charge); @@ -657,7 +657,7 @@ void LocalPlayer::addJournalItems() { for (unsigned int i = 0; i < journalChanges.count; i++) { - mwmp::JournalItem journalItem = journalChanges.journalItems[i]; + mwmp::JournalItem journalItem = journalChanges.journalItems.at(i); if (journalItem.type == JournalItem::ENTRY) { @@ -688,7 +688,7 @@ void LocalPlayer::removeItems() for (unsigned int i = 0; i < inventoryChanges.count; i++) { - mwmp::Item item = inventoryChanges.items[i]; + mwmp::Item item = inventoryChanges.items.at(i); ptrStore.remove(item.refId, item.count, ptrPlayer); } } diff --git a/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp b/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp index 1c6a6038a..523fb396a 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerCellState.cpp @@ -26,7 +26,7 @@ void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, mwmp::BasePlayer if (send) { - cellState = player->cellStateChanges.cellStates[i]; + cellState = player->cellStateChanges.cellStates.at(i); } RW(cellState.type, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp b/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp index a3c0f8f2c..65f153edc 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerInventory.cpp @@ -32,7 +32,7 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bo if (send) { - item = player->inventoryChanges.items[i]; + item = player->inventoryChanges.items.at(i); } RW(item.refId, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp b/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp index cc1393ad5..92394cfad 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerJournal.cpp @@ -25,7 +25,7 @@ void PacketPlayerJournal::Packet(RakNet::BitStream *bs, BasePlayer *player, bool JournalItem journalItem; if (send) - journalItem = player->journalChanges.journalItems[i]; + journalItem = player->journalChanges.journalItems.at(i); RW(journalItem.type, send); RW(journalItem.quest, send); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp index c7efdc01a..5671542e9 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp @@ -28,7 +28,7 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, BasePlayer *player, bo if (send) { - spell = player->spellbookChanges.spells[i]; + spell = player->spellbookChanges.spells.at(i); } RW(spell.mId, send); diff --git a/components/openmw-mp/Packets/World/PacketContainer.cpp b/components/openmw-mp/Packets/World/PacketContainer.cpp index b6b31ae27..9c2687b98 100644 --- a/components/openmw-mp/Packets/World/PacketContainer.cpp +++ b/components/openmw-mp/Packets/World/PacketContainer.cpp @@ -39,7 +39,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); @@ -57,7 +57,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send { if (send) { - containerItem = event->containerChanges.items[i]; + containerItem = event->containerChanges.items.at(i); } RW(containerItem.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketDoorState.cpp b/components/openmw-mp/Packets/World/PacketDoorState.cpp index 61e0e060d..2682e8be7 100644 --- a/components/openmw-mp/Packets/World/PacketDoorState.cpp +++ b/components/openmw-mp/Packets/World/PacketDoorState.cpp @@ -30,7 +30,7 @@ void PacketDoorState::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketMusicPlay.cpp b/components/openmw-mp/Packets/World/PacketMusicPlay.cpp index c408bebeb..73b25e786 100644 --- a/components/openmw-mp/Packets/World/PacketMusicPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketMusicPlay.cpp @@ -25,7 +25,7 @@ void PacketMusicPlay::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.filename, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp index 32515600d..9997c8bfb 100644 --- a/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectAnimPlay.cpp @@ -30,7 +30,7 @@ void PacketObjectAnimPlay::Packet(RakNet::BitStream *bs, WorldEvent *event, bool { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectDelete.cpp b/components/openmw-mp/Packets/World/PacketObjectDelete.cpp index 6e2dc1514..b577243a0 100644 --- a/components/openmw-mp/Packets/World/PacketObjectDelete.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectDelete.cpp @@ -30,7 +30,7 @@ void PacketObjectDelete::Packet(RakNet::BitStream *bs, WorldEvent *event, bool s { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectLock.cpp b/components/openmw-mp/Packets/World/PacketObjectLock.cpp index 78aa25881..2adf302b0 100644 --- a/components/openmw-mp/Packets/World/PacketObjectLock.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectLock.cpp @@ -30,7 +30,7 @@ void PacketObjectLock::Packet(RakNet::BitStream *bs, WorldEvent *event, bool sen { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectMove.cpp b/components/openmw-mp/Packets/World/PacketObjectMove.cpp index 667ff8710..30b79f65f 100644 --- a/components/openmw-mp/Packets/World/PacketObjectMove.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectMove.cpp @@ -30,7 +30,7 @@ void PacketObjectMove::Packet(RakNet::BitStream *bs, WorldEvent *event, bool sen { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp index 2e726f37c..9c97a7bc5 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp @@ -30,7 +30,7 @@ void PacketObjectPlace::Packet(RakNet::BitStream *bs, WorldEvent *event, bool se { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp index 4afd483df..d0038499d 100644 --- a/components/openmw-mp/Packets/World/PacketObjectRotate.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectRotate.cpp @@ -30,7 +30,7 @@ void PacketObjectRotate::Packet(RakNet::BitStream *bs, WorldEvent *event, bool s { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectScale.cpp b/components/openmw-mp/Packets/World/PacketObjectScale.cpp index 14a0c8e13..64671601e 100644 --- a/components/openmw-mp/Packets/World/PacketObjectScale.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectScale.cpp @@ -30,7 +30,7 @@ void PacketObjectScale::Packet(RakNet::BitStream *bs, WorldEvent *event, bool se { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp index 28fb7ff4c..174105319 100644 --- a/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectUnlock.cpp @@ -30,7 +30,7 @@ void PacketObjectUnlock::Packet(RakNet::BitStream *bs, WorldEvent *event, bool s { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp index 4da95f22d..3a58c1e9d 100644 --- a/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptGlobalShort.cpp @@ -25,7 +25,7 @@ void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, WorldEvent *event, b { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.varName, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp index 7991acace..693ce9b86 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalFloat.cpp @@ -30,7 +30,7 @@ void PacketScriptLocalFloat::Packet(RakNet::BitStream *bs, WorldEvent *event, bo { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp b/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp index a8faefcad..34ced66c0 100644 --- a/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptLocalShort.cpp @@ -30,7 +30,7 @@ void PacketScriptLocalShort::Packet(RakNet::BitStream *bs, WorldEvent *event, bo { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp b/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp index 80d84f1be..24bc9e68e 100644 --- a/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp +++ b/components/openmw-mp/Packets/World/PacketScriptMemberShort.cpp @@ -25,7 +25,7 @@ void PacketScriptMemberShort::Packet(RakNet::BitStream *bs, WorldEvent *event, b { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.refId, send); diff --git a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp index 283111acd..74f2a0050 100644 --- a/components/openmw-mp/Packets/World/PacketVideoPlay.cpp +++ b/components/openmw-mp/Packets/World/PacketVideoPlay.cpp @@ -25,7 +25,7 @@ void PacketVideoPlay::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send { if (send) { - worldObject = event->objectChanges.objects[i]; + worldObject = event->objectChanges.objects.at(i); } RW(worldObject.filename, send);