Raised This Month: $32 Target: $400
 8% 

Registering SM handle type


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-30-2010 , 06:06   Registering SM handle type
Reply With Quote #1

WinXP SP3, VS 2010.
PHP Code:
const char *HandleTypes[] =
{
   
"ABC",
   
"DEF"
   
//etc
}
void Foo(void)
{
    
//According to debugger:
    //HandleTypes[0] type is "char *"
    //HandleTypes[0] value is "ABC"
    
handlesys->CreateType(HandleTypes[0], ...); //HandleError_Parameter

PHP Code:
void Foo(void)
{
    const 
char *HandleTypes[] =
     {
        
"ABC",
        
"DEF"
        
//etc
     
}
    
//According to debugger:
    //HandleTypes[0] type is "const char *"
    //HandleTypes[0] value is "ABC"
    
handlesys->CreateType(HandleTypes[0], ...); //No errors

What the hell? Why?
__________________

Last edited by FaTony; 12-30-2010 at 08:00.
FaTony is offline
pRED*
Join Date: Dec 2006
Old 01-01-2011 , 03:21   Re: Registering SM handle type
Reply With Quote #2

Of the 3 possible reasons that error could occur, only attempting to register an already existing name seems relevant.

The given code example looks to be fine, sure you didn't inadvertently fix another issue while changing that?
pRED* is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-01-2011 , 14:16   Re: Registering SM handle type
Reply With Quote #3

No, it seems to be how Windows manages memory. You see that debugger identify same variables as different types based on the scope. And handle type names I use in my extension are rather unique. What are the other 2 possible reasons?
__________________

Last edited by FaTony; 01-01-2011 at 14:46.
FaTony is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 01-01-2011 , 17:50   Re: Registering SM handle type
Reply With Quote #4

SM is open source, you can figure that out yourself by searching CreateType for HandleError_Parameter.

It will set err to HandleError_Parameter if the dispatch parameter you gave is null, you give a bad parent type, or you register the same name more than once.
Fyren is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-01-2011 , 22:09   Re: Registering SM handle type
Reply With Quote #5

You are right. I guess I'll wait for the next stable SM build and compile it myself to see everything through debugger. I'm currently on snapshot and the source code I have does not match my binaries.
__________________
FaTony is offline
BAILOPAN
Join Date: Jan 2004
Old 01-04-2011 , 01:22   Re: Registering SM handle type
Reply With Quote #6

Full line of code would be good, another parameter could be at fault
__________________
egg
BAILOPAN is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-05-2011 , 14:55   Re: Registering SM handle type
Reply With Quote #7

http://forums.alliedmods.net/showthread.php?t=146674

SPVTypeHandler.cpp

There are both cases in there. Just comment local array and uncomment global.
__________________
FaTony is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 01-14-2011 , 18:29   Re: Registering SM handle type
Reply With Quote #8

Hm this is weird.
Does this happen with all of your 3 handle types or only one (if yes, which one) of them?

Maybe try something like
Code:
printf("%d: %x %s\n", i, SPVTypeNames[i], SPVTypeNames[i]);
typebuffer[i].type = handlesys->CreateType(...);
printf("%d: %x %s\n", i, SPVTypeNames[i], SPVTypeNames[i]);
printf("Result: %d\n\n", typebuffer[i].type);
(replace printf with some other printing/logging mechanism that you can see)

That way you can see:
- what exactly was passed into CreateType (address of name and string value stored on that address)
- if something modifies the values in the process

As far as the code SM goes, I don't see any reason why it would do this
__________________
hello, i am pm
PM is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-17-2011 , 16:30   Re: Registering SM handle type
Reply With Quote #9

Ok, will try in a couple of days.
__________________
FaTony is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 02-27-2011 , 17:58   Re: Registering SM handle type
Reply With Quote #10

Quite strange, that issue seems to have been resolved by itself. Must've been a snapshot.
__________________

Last edited by FaTony; 02-27-2011 at 18:10.
FaTony 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:43.


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