Raised This Month: $12 Target: $400
 3% 

How is this a tag mismatch?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-15-2010 , 04:09   How is this a tag mismatch?
Reply With Quote #1

Code:
/**
 * List of available sdktools functions.
 */
enum SDKLibCalls
{
    #if defined PROJECT_GAME_CSS
    SDKLibCall_TerminateRound,      /** Terminate the round with a given reason. */
    SDKLibCall_CSWeaponDrop,        /** Force client to drop weapon. */
    SDKLibCall_FlashlightIsOn,      /** Check is a client's flashlight is on. */
    SDKLibCall_FlashlightTurnOn,    /** Turn a client's flashlight on. */
    SDKLibCall_FlashlightTurnOff,   /** Turn a client's flashlight off. */
    #endif
}

/**
 * Handles to all the pre-defined sdkcalls.
 */
new Handle:g_hSDKCall[SDKLibCalls];

/**
 * Terminates the round. (CS:S)
 * 
 * @param delay     Time to wait before new round starts.
 * @param reason    Round end reason.  See enum RoundEndReasons.
 */
stock SDKToolsLib_TerminateRound(Float:delay, RoundEndReasons:reason)
{
    SDKCall(g_hSDKCall[SDKLibCall_TerminateRound], delay, _:reason);
}

/**
 * Forces client to drop a weapon. (CS:S)
 * 
 * @param client    The client index.
 * @param weapon    The weapon entity index to force client to drop.
 */
stock SDKToolsLib_CSWeaponDrop(client, weapon)
{
    SDKCall(g_hSDKCall[SDKLibCall_CSWeaponDrop], client, weapon, true, false);
}

g_hSDKCall is defined as type Handle, yet the first parameter of SDKCall is saying it's not.

I verified it is this parameter because if I put "Handle:" in front of g_hSDKCall then the warning goes away. But I don't think there should be a warning at all?
__________________
Greyscale is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 07-15-2010 , 11:49   Re: How is this a tag mismatch?
Reply With Quote #2

Pawn's enum hack sucks. Try using
Code:
enum _:SDKLibCalls {
Seta00 is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-15-2010 , 13:51   Re: How is this a tag mismatch?
Reply With Quote #3

That created more tag mismatch warnings in lines that use any of the items in the enum. (The previous ones still remain)

I know I can fix it by reading it as a Handle, I'm just wondering if there's something I'm doing wrong or if it's a compiler bug?
__________________
Greyscale is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-15-2010 , 14:06   Re: How is this a tag mismatch?
Reply With Quote #4

I think I may have figured it out.

When referencing an enum item directly, it uses the type of that item. So above since SDKLibCall_TerminateRound doesn't have "Handle:" before it in the enum then when I use it it's reading it as an integer.

But if I use an "SDKLibCalls"-typed variable then it would read the type of the array.
Code:
new SDKLibCalls:sdkcall = SDKLibCall_TerminateRound;
SDKCall(g_hSDKCall[sdkcall], client, delay, _:reason);
So that compiles without warning. Kind of sucks that I have to tag every item as Handle though. But I'm assuming that's just Pawn's design.

EDIT: Just realized I can't tag each one as a handle because multiple arrays are using that enum.

This seems like a design flaw. It should be taking the tag of the array not the enum member. Any SM devs have anything to say about this?
__________________

Last edited by Greyscale; 07-15-2010 at 14:19.
Greyscale is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 07-15-2010 , 16:53   Re: How is this a tag mismatch?
Reply With Quote #5

Quote:
Originally Posted by Greyscale View Post
This seems like a design flaw. It should be taking the tag of the array not the enum member. Any SM devs have anything to say about this?
It is a design flaw, and has been on the Pawn interpreter since AMX Mod X. Someone should really give it a look.

EDIT: It's not. Read the whole thread.

Last edited by Seta00; 07-16-2010 at 08:12.
Seta00 is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-16-2010 , 01:23   Re: How is this a tag mismatch?
Reply With Quote #6

I can see how this is a tough problem to solve, though. Because sometimes I need to tag each enum member with a specific data type. The question is how can we tell the compiler what we want? The tag of the member or of the array.
__________________
Greyscale is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-16-2010 , 01:38   Re: How is this a tag mismatch?
Reply With Quote #7

lol that compiles fine for me , no warnings or anything


PHP Code:

/* Plugin Template generated by Pawn Studio */

#include <sourcemod>
#include <sdktools>

public Plugin:myinfo 
{
    
name "New Plugin",
    
author "Unknown",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

public 
OnPluginStart()
{
    
// Add your own code here...
}

/**
 * List of available sdktools functions.
 */
enum SDKLibCalls
{
    
#if defined PROJECT_GAME_CSS
    
SDKLibCall_TerminateRound,      /** Terminate the round with a given reason. */
    
SDKLibCall_CSWeaponDrop,        /** Force client to drop weapon. */
    
SDKLibCall_FlashlightIsOn,      /** Check is a client's flashlight is on. */
    
SDKLibCall_FlashlightTurnOn,    /** Turn a client's flashlight on. */
    
SDKLibCall_FlashlightTurnOff,   /** Turn a client's flashlight off. */
    #endif
}

/**
 * Handles to all the pre-defined sdkcalls.
 */
new Handle:g_hSDKCall[SDKLibCalls];

/**
 * Terminates the round. (CS:S)
 * 
 * @param delay     Time to wait before new round starts.
 * @param reason    Round end reason.  See enum RoundEndReasons.
 */
stock SDKToolsLib_TerminateRound(Float:delayRoundEndReasons:reason)
{
    
SDKCall(g_hSDKCall[SDKLibCall_TerminateRound], delay_:reason);
}

/**
 * Forces client to drop a weapon. (CS:S)
 * 
 * @param client    The client index.
 * @param weapon    The weapon entity index to force client to drop.
 */
stock SDKToolsLib_CSWeaponDrop(clientweapon)
{
    
SDKCall(g_hSDKCall[SDKLibCall_CSWeaponDrop], clientweapontruefalse);

Double Checked on web compiler and worked as well no errors or warnings

EDIT: i also don't get any erros when I take the handle out from the new g_hSDKCall[SDKLibCalls];
__________________

Last edited by Peoples Army; 07-16-2010 at 02:05.
Peoples Army is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-16-2010 , 02:06   Re: How is this a tag mismatch?
Reply With Quote #8

Because they are stocks and never referenced, so they are ignored by the compiler. In the real source they are used. Change |stock| to |public| and you'll see the warnings.
__________________
Greyscale is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-16-2010 , 02:09   Re: How is this a tag mismatch?
Reply With Quote #9

where are these defined?

PHP Code:

SourcePawn Compiler 1.3.3
Copyright 
(c1997-2006ITB CompuPhase, (C)2004-2008 AlliedModdersLLC

E
:\game development\sourcemod\sps\test.sp(37) : error 009invalid array size (negativezero or out of bounds)
E:\game development\sourcemod\sps\test.sp(47) : error 017undefined symbol "SDKLibCall_TerminateRound"
E:\game development\sourcemod\sps\test.sp(58) : error 017undefined symbol "SDKLibCall_CSWeaponDrop"

3 Errors.

Compilation Time0.83 sec 
__________________
Peoples Army is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-16-2010 , 02:12   Re: How is this a tag mismatch?
Reply With Quote #10

Remove

#if defined PROJECT_GAME_CSS
and
#endif
__________________
Greyscale is offline
Reply


Thread Tools
Display Modes

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 08:56.


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