worldserver crash

Welcome in the osRose emulator Project.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Re: worldserver crash

Postby lmame on Thu Sep 11, 2008 1:08 pm

PurpleYouko wrote:It's always best to protect against people tampering with stuff i guess.
I will add some checks for the next revision. ;)


In fact you're using (like us) a <vector> and an array. Array beeing for index and often this one causes problems :)
You should look how we handle it in osrose (dev rev) since I did some checks for those kind of stuffs (all that use index array) and I used defines so you just need to change one line to expand an array.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: worldserver crash

Postby PurpleYouko on Thu Sep 11, 2008 1:59 pm

yes we are using a vector (for the actual items) and an array (for the index)
The simplest thing to do is simply check whether the index value has reached the maximum defined size of the array and if it has, just don't add the item, send a warning and return false from the function.

I will take a look at how you did it in osrose.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: worldserver crash

Postby lmame on Thu Sep 11, 2008 2:56 pm

We do exactly that.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: worldserver crash

Postby Drakia on Thu Sep 11, 2008 3:31 pm

Or... use a map :)
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: worldserver crash

Postby PurpleYouko on Thu Sep 11, 2008 4:07 pm

Drakia wrote:Or... use a map :)


When i use a map to show an array all i get is this :(
array.jpg
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: worldserver crash

Postby Drakia on Thu Sep 11, 2008 4:24 pm

No, no, Maps!
The speed isn't too much slower than a Vector for access (Vectors run in linear time, this runs in logarithmic, they are the two fastest access times). But you avoid having to use a seperate list for the index, you just use EquipList[0][itemid]->id;
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: worldserver crash

Postby PurpleYouko on Thu Sep 11, 2008 5:35 pm

So that is really just a 2 dimesional array, or an array of arrays if you like.
I use them all the time in my VB programing.
I actually use some code like that in my drops system too
  1.  
  2.                 itemnumber[n] = thisdrop->itemnum;
  3.                 itemtype[n] = thisdrop->itemtype;
  4.                 //probability[n] = thisdrop->prob;
  5.                 alternate[n][0] = 0;
  6.                 for(int i=1;i<8;i++)
  7.                 {
  8.                     alternate[n][i] = thisdrop->alt[i];
  9.                 }
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: worldserver crash

Postby Drakia on Thu Sep 11, 2008 6:12 pm

Well, not quite. The first [0] was the array of EquipLists (There's like 10 or something), the second [itemnum] is the Map.
It is a key->value pair, where the key can be any data type (From a number, to a string, to a custom data type) and the value can be any data type (we'd use a pointer to an item).
So, you can access any item by just going EquipList[0][itemnum] instead of EquipList[0].index[itemnum] and depending on a fixed-size array of index's. Using a Map, we would avoid the pitfalls of the fixed-size array (STB being too large for the array). I recommend you go read about them, it'll make things easier.
My favorite skill is scaring new users away.
If you haven't SEARCHED expect me to yell at you.
Image
Drakia
ospRose dev team
ospRose dev team
 
Posts: 1614
Joined: Tue Sep 18, 2007 6:53 am
Location: Nanaimo, BC, Canada

Re: worldserver crash

Postby Maxxon on Thu Sep 11, 2008 7:01 pm

why so complicated? load the STB, ask it then how many rows it has and then allocate memory according to that. there is no need to be static.

for example change CEquipList to
  1.  
  2. // ITEMS
  3. struct CEquipList
  4. {
  5.     //CEquip *Index[5000];
  6.     CEquip **Index;
  7.     vector<CEquip*> Data;
  8.     CEquip* nullequip;
  9. };
  10.  


in the STB Loading you would need something like

  1.  
  2.     // Load Weapons Items
  3.         CSTBData eqData;
  4.     STBStoreData(filename, &eqData);
  5.  
  6.     EquipList[WEAPON].Index = new CEquip*[eqData.rowcount];
  7.  


access to the index array remains the same. so you dont even need to change code (you can still access the index array with [] if you declare it as above and it would be dynamic then). You can even delete the whole part with vectors since you do all access through the Index Array anyway.
Image
an anymous comment on a program called reloader:
what if a fatal error happens, will it restart it?
User avatar
Maxxon
Hawker's pet
Hawker's pet
 
Posts: 1305
Joined: Sat Nov 10, 2007 12:42 pm

Previous

Return to Support - OspRose Emulator

Who is online

Users browsing this forum: No registered users and 9 guests

cron