Raised This Month: $ Target: $400
 0% 

TFC skills rank with speed run timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jRaven
AMX Mod X Beta Tester
Join Date: Jan 2006
Location: IA, USA
Old 09-15-2006 , 14:40   Re: TFC skills rank with speed run timer
Reply With Quote #1

Re: segfaults...
With binary logging I found the dbi_result native does not return.
I posted this in beta testing and hopefully we can get it worked out soon.
I'm still hunting ...can't wait to enable this on my tfc server...
jRaven is offline
Send a message via ICQ to jRaven Send a message via AIM to jRaven
BAILOPAN
Join Date: Jan 2004
Old 09-15-2006 , 20:50   Re: TFC skills rank with speed run timer
Reply With Quote #2

FYI: I found why this plugin was crashing. You're mishandling dbi_nextrow(). dbi_nextrow() returns 0 when there are no more results. In a few places in this plugin (around 976) you make while loops eating up results, and then call dbi_result() on the query. But by the time you get to dbi_result(), the result set will be entirely gone, as dbi_nextrow() will have finished looping them all.

So, recheck your code for dbi_nextrow() usage. If you know the last call returned 0, you should not be checking any more rows or trying to get results. Furthermore, you should never call dbi_nextrow() without checking the result.

Unfortunately, I can't really fix this fully, as what you're doing violates the original API definitions (the fact that it worked in 1.71 was a coincidence of some sort). Instead, I've prevented this crash in 1.76, and replaced it with a silent failure. Your plugin will run but it may be getting stale or incorrect data, so I suggest fixing this.

If you've any questions about corrections or would like me to verify new code, please feel free to PM me.
__________________
egg

Last edited by BAILOPAN; 09-15-2006 at 20:52.
BAILOPAN is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 09-16-2006 , 03:55   Re: TFC skills rank with speed run timer
Reply With Quote #3

Thanks. I see whats wrong. I used a lazy method to find the last row in the result set instead of using dbi_num_rows ( result ) and pick the last row from there. Ill try and fix this. Actually I think that there is only one place where this problem occurs.

Thx for looking into it

/Lt.
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 09-16-2006 , 04:41   Re: TFC skills rank with speed run timer
Reply With Quote #4

Ok, it was as I thought. This problem only occured in one place in the plugin.
I changed

Code:
        dbi_nextrow(resultMaps)         dbi_result(resultMaps, "curDate", qryFirstDate, maxFinishedMaps-1)         len1 += format(statsMotd[len1], 2047-len1,"First time you finished a map: %s^n",qryFirstDate)         while (resultMaps && dbi_nextrow(resultMaps) > 0)             dbi_nextrow(resultMaps)         dbi_result(resultMaps, "curDate", qryFirstDate, maxFinishedMaps-1)         len1 += format(statsMotd[len1], 2047-len1,"Last time you finished a map: %s^n^n^n",qryFirstDate)         dbi_free_result(resultMaps)

to

Code:
        dbi_nextrow(resultMaps)         dbi_result(resultMaps, "curDate", qryFirstDate, maxFinishedMaps-1)         new nRows = dbi_num_rows(resultMaps)         new incrRows = 1         len1 += format(statsMotd[len1], 2047-len1,"First time you finished a map: %s^n",qryFirstDate)         while (incrRows < nRows) {             dbi_nextrow(resultMaps)             ++incrRows         }         dbi_result(resultMaps, "curDate", qryFirstDate, maxFinishedMaps-1)         len1 += format(statsMotd[len1], 2047-len1,"Last time you finished a map: %s^n^n^n",qryFirstDate)         dbi_free_result(resultMaps)

In this way, as Bailopan said, I'm shure not to query an empty result set.
I was only interested in the last row in the result set. This is a better way to do it.

Thanks for helping out

/Lt.
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
jRaven
AMX Mod X Beta Tester
Join Date: Jan 2006
Location: IA, USA
Old 09-16-2006 , 18:06   Re: TFC skills rank with speed run timer
Reply With Quote #5

Great work! Thanks Lt Llama, Bail!
jRaven is offline
Send a message via ICQ to jRaven Send a message via AIM to jRaven
-hi-
Member
Join Date: Jul 2006
Old 09-16-2006 , 19:50   Re: TFC skills rank with speed run timer
Reply With Quote #6

I noticed you are using arrays with 32 slots for storing information about players. It's possible for a player to have an ID of 32, and 32 isn't a legal slot in the arrays. I would change all the id based arrays to have 33 slots.

EDIT:
It still crashes when anyone uses the /top5 command. I'm using 1.75a

Last edited by -hi-; 09-16-2006 at 23:16.
-hi- is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 09-17-2006 , 03:47   Re: TFC skills rank with speed run timer
Reply With Quote #7

Quote:
Originally Posted by -hi- View Post
I noticed you are using arrays with 32 slots for storing information about players. It's possible for a player to have an ID of 32, and 32 isn't a legal slot in the arrays. I would change all the id based arrays to have 33 slots.

EDIT:
It still crashes when anyone uses the /top5 command. I'm using 1.75a
Hm, I don't get it. Where to change the slots?
If I look for example in the official amxmodx plugins they use 32 slots.
For example in admincmd.sma:

Code:
new authid[32], authid2[32], name2[32], name[32], userid2, reason[32] get_user_authid(id, authid, 31) get_user_authid(player, authid2, 31) get_user_name(player, name2, 31) get_user_name(id, name, 31)

Are those such places I should change? If not, can you point out an example where I should change it?

I'll have a look at the crash problem. Btw, do you have less than 5 rows in your database? Thats the only reason when I think it would crash. I use 1.75a to but my skillsrank tables are packed ?

/Lt.
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.

Last edited by Lt Llama; 09-17-2006 at 04:08.
Lt Llama is offline
-hi-
Member
Join Date: Jul 2006
Old 09-17-2006 , 04:17   Re: TFC skills rank with speed run timer
Reply With Quote #8

Yes, my DB is practically empty.

I'm talking about places where you use a player's ID number (which can be 1-32) as an index in an array:

Code:
new bool:hasTimer[32]

Then later in the code you use the player's ID number to set things in the array:

Code:
hasTimer[id] = false

Since the player ID can be 32, this code would be wrong since the legal indices for an array of size 32 are 0-31:

Code:
hasTimer[32] = false

Last edited by -hi-; 09-17-2006 at 04:20.
-hi- is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 09-17-2006 , 06:32   Re: TFC skills rank with speed run timer
Reply With Quote #9

Ok, it still crashed when there where fewer than 5 players to pick for the top5 lists. I have created two versions of a changed plugin.

skillranks_oldtables.sma

This is a version which use the same table names as the original skillsrank1.4.3.

skillranks_testtables.sma

This is a version which creates new tables only to use for testing.
testmaps = substitutes the original 'skillmaps' table
testrank = substitutes the original 'skillrank' table

Can you download and test these and see if it works now?
If you dont want to mess with your old tables use skillsrank_testtables.sma.

It works for me, I have tried creating new tables and used the old ones.

Confirm that it works for you to and I will update the plugin.

Quote:
Originally Posted by -hi- View Post
I noticed you are using arrays with 32 slots for storing information about players. It's possible for a player to have an ID of 32, and 32 isn't a legal slot in the arrays. I would change all the id based arrays to have 33 slots.
I have changed where I thought I had to change.
If you have time -hi-, can you have a little look and tell me if I need to change anywhere else?

Ok, hope it works now

/Lt.
Attached Files
File Type: sma Get Plugin or Get Source (skillranks_oldtables.sma - 620 views - 60.9 KB)
File Type: sma Get Plugin or Get Source (skillranks_testtables.sma - 627 views - 60.8 KB)
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
-hi-
Member
Join Date: Jul 2006
Old 09-17-2006 , 07:33   Re: TFC skills rank with speed run timer
Reply With Quote #10

Ya the testtables version worked for me with only 1 row in the DB. Thanks for the quick fix!
-hi- is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode