So in debug modes its returning the first WorldId what i have in Lua.
So that is now working.
However when i do nWorldId = rand() % m_vecRndInfo.at(i).dwWorldID;
Then its giving me random numbers even numbers that are not stored inside the .lua file.
In your code:
for (int i = 0; i < (int)m_vecRndInfo.size(); i++) There is no need of that, you don't need to loop.
nWorldId = rand() % m_vecRndInfo.at(i).dwWorldID; For example, Kalgas cave (world id 130) would be rand() % 130; Still no sense.
Code:
void CRiftMatch::SetRandomWorld()
{
vector<__RANDOM_WORLD> m_vecRndInfo = CRiftMng::GetInstance()->m_vecWorld;
int id = rand() % m_vecRndInfo.size();
nWorldId = m_vecRndInfo[id].dwWorldID;
}
int id = rand() % m_vecRndInfo.size(); Returns a random number between 0 and the size of vector
nWorldId = m_vecRndInfo[id].dwWorldID; From the previous obtained operation (vector position) use the giving number to get the value from structure.
This only fails if there is no data stored in the vector, consider using assert() if needed.
In your code:
for (int i = 0; i < (int)m_vecRndInfo.size(); i++) There is no need of that, you don't need to loop.
nWorldId = rand() % m_vecRndInfo.at(i).dwWorldID; For example, Kalgas cave (world id 130) would be rand() % 130; Still no sense.
Code:
void CRiftMatch::SetRandomWorld()
{
vector<__RANDOM_WORLD> m_vecRndInfo = CRiftMng::GetInstance()->m_vecWorld;
int id = rand() % m_vecRndInfo.size();
nWorldId = m_vecRndInfo[id].dwWorldID;
}
int id = rand() % m_vecRndInfo.size(); Returns a random number between 0 and the size of vector
nWorldId = m_vecRndInfo[id].dwWorldID; From the previous obtained operation (vector position) use the giving number to get the value from structure.
This only fails if there is no data stored in the vector, consider using assert() if needed.
Your code is working the only thing i am facing is that i will always just show 1 WorldID.
I have taken the code from Colloseum.cpp and altered it.
Guess its an fault in there.
EDIT!!!
SOLVED.
Pfff. i have taken an closer look on how its loading the Worlds
And sure enought it was the return FALSE; this leads to execute one time. same as break;
Changed it to true problem solved.
Thank you verry much for your help and your link to the vector i have learned an lot from it.
Vector ? 10/17/2014 - C/C++ - 6 Replies Hey,
wollte mal etwas Fragen (2 sachen).
Ich verende Vectoren(möchte sie verwenden) in einen TCP Server den ich im Moment schreibe.
Ich habe 2 Threads die die Vectors erstmal bearbeiten.
Code:
DWORD TCP_Server::Client_Accept_Thread()
{
sockaddr_in Clientinfo;
int Clientinfolen = sizeof(Clientinfo);
C# array of tabControls, creating new tabs by template 08/12/2014 - .NET Languages - 0 Replies EDIT: I found a way to do that, anyone willing to check my code If it can be better or contains any mistakes
I need to create new tabControl with tabPages content inside tabPage, but I am still at the beginning
this creates pages I want, then I need to create in each page new tabControl
http://oi59.tinypic.com/1597gg.jpg
for (int i = 0; i < l_Controller.Player.VillageCount; i++)
{
[c++] help with sub-vector 05/22/2014 - C/C++ - 8 Replies Well, i have a vector that stores objects of my class named 'Tools':
vercotr<Tools>myvect
that has lets say 5 objects saved in it... But now i want to make a method that makes a subvector from lets say 2nd (start) to 4th (end/finish) element in myvect and returns that newly created subvector.
returnSubvect(2,4); that is returning: subvect
Can anyone explain me how to do this? -Was strugling with this for some time now, but i cant get it to work.
Vector out of bounce 06/05/2013 - C/C++ - 7 Replies try
{
return MapContainer.at(index) ;
}
catch (std::exception& e)
{
std::cout << "Element " << index << ": index exceeds vector dimensions." << std::endl;
}
Mw2 Vector 05/12/2011 - Call of Duty - 9 Replies Stimmt das wenn man Schaldämpfer raufschrauft dass sich die Vector nicht mehr so verzieht