c++
#include <iostream>
#include <vector>
using namespace std;
class CDoorTile
{
public:
struct Info
{
int m_Index;
int m_Number;
};
std::vector<Info> m_vTiles;
};
class CDoorTile *m_pDoor;
int main()
{
int Height = 10;
int Width = 20;
m_pDoor = new CDoorTile[Height * Width];
for (int i = 0; i < Width * Height; i++)
{
CDoorTile::Info Data;
Data.m_Index = 5;
Data.m_Number = i+1;
m_pDoor[i].m_vTiles.push_back(Data);
}
int Found = -1;
int Index = 7;
for (unsigned int i = 0; i < m_pDoor[Index].m_vTiles.size(); i++)
if (m_pDoor[Index].m_vTiles[i].m_Number == 8)
{
Found = i;
break;
}
if (Found != -1)
{
cout << Found << "\n";
cout << m_pDoor[Index].m_vTiles.size() << "\n";
m_pDoor[Index].m_vTiles.erase(m_pDoor[Index].m_vTiles.begin() + Found);
}
return 0;
}
@heinrich5991 this is basically what i am doing. And it works in this example, as expected. I have no idea why it would not work in the tw base.m_pDoor
array is empty, if I understand it correctly?c++
int CCollision::GetDoorIndex(int Index, int Number)
{
for (unsigned int i = 0; i < m_pDoor[Index].m_vTiles.size(); i++)
if (m_pDoor[Index].m_vTiles[i].m_Number == Number)
return i;
return -1;
}
m_pDoor[Index]
is out of bounds, I meanIndex
*m_pDoors[Index]
aka m_pDoors[102882]
for (std::vector<CDoorTile::SInfo>::iterator i = m_pDoor[Index].m_vTiles.begin(); i != m_pDoor[Index].m_vTiles.end(); i++)
{
}
()
does not change that)new Object
and new Object()
were equivalentT object
and new T
is initialized the same wayT object
, then everything non-primitive in my object of class T
is initializednew T()
that is not initialized by new T
?new T
as far as I understand itnew test()
?-Wclass-memaccess
-Wclass-memaccess
-Weverything
that might actually be what one would think of when you say -Wall
-Wall
as more of an "all stable diagnostics of highish quality"int x; // declare an int named x
virtual void CComponent::OnMessage(int Msg, void *pRawMsg)
Called when receiving a network message."pRawMsg
is (a pointer to a struct corresponding to Msg
)virtual void CComponent::OnReset()
Called to reset the component. This method is usually called on your component constructor to avoid code duplication." this is an example of a not so good comment. it starts by stating the obvious, but doesn't tell me what I'm allowed to do in the method and what not. when is it called? I think it was when you disconnect?Sendable
constraint and a bool Send(Sendable auto s) { ... }
template<>
mess, No std::enable_if
,
seperated list of strings/ integers etc., instead of formatting
not always the best solution(e.g. localization) but nice to use if you just want to spam out textSendable
constraint and a bool Send(Sendable auto s) { ... }
f3b0a1e
Add ClPredictionMargin - trml
e7f13bc
Only use configured prediction margin on servers with predictable/synced weapon input - trml
30093e4
Remove extra projectiles - trml
b4a99fe
Revert "Split CInput::NextFrame() from CInput::Update() (fixes #444)" - Robyt3
7987959
refactor mouse state handling - Robyt3
6675de3
do not copy keyboard over mouse state, refactoring - Robyt3
3557bea
reduce indentation of input event handling code - Robyt3
bbc194c
use info provided by sdl for mouse double clicks - oy
e3b2069
end double mouse click state when doing a new single click. - oy
c495d4b
change type of MouseDoubleClick from int to bool - Robyt3
c214918
only consume double click if item hot - Robyt3
d54a799
Fix compiler warning with ffmpeg 5.0 - def-
48e5347
Merge #4581 #4590 #4593 #4607 - bors[bot]