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

Solved Beginner Needing Help - Updating Old Code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
High Cookie
New Member
Join Date: Jan 2024
Old 01-20-2024 , 22:13   Beginner Needing Help - Updating Old Code.
Reply With Quote #1

Hi team,

I am in the process of trying to update this so I can play it again:

https://github.com/Tabbernaut/L4D2-Random

While I have made progress I have ran into an issue and I would like some guidance on how to tactle it. In the l4d2_random.sp at line 255-ish we have this piece of code:

Code:
     
// Blind infected
    g_hBlockedEntities = CreateArray(_:EntInfo);
    CreateTimer(BLND_ENT_CHECK_INTERVAL, Timer_EntCheck, _, TIMER_REPEAT);
I have changed EntInfo to an Enum Struct but not sure first what the _: synatx does or how to deal with a dynamic array with an Enum Struct.

I would appreciate any help including any general tips for updating older code such as this.

Thanks.

Last edited by High Cookie; 01-25-2024 at 22:48. Reason: I got my answser :)
High Cookie is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-21-2024 , 04:05   Re: Beginner Needing Help - Updating Old Code.
Reply With Quote #2

So this is Legacy SourcePawn syntax back then.
https://github.com/Tabbernaut/L4D2-R...s.sp#L711-L717
PHP Code:
// Legacy code
enum EntInfo                        // for blind_infected adaptation
{
            
iEntity,
    
bool:   hasBeenSeen
}

myfunction()
{
    
// you got enum array size with _:EntInfo I guess


This is current, new one
https://forums.alliedmods.net/showthread.php?t=312822

enum and enum structs are syntatic sugar in code, it almost just a array.

You can either try this way.

PHP Code:
Handle g_hBlockedEntities;

enum struct EntInfo
{
    
int    iEntity;
    
bool    hasBeenSeen;
}

void nothing()
{
    if(
g_hBlockedEntities == null)
        
g_hBlockedEntities CreateArray(sizeof(EntInfo));


    
EntInfo currentEntanotherEnt;

    
// random nums
    
currentEnt.iEntity 69;
    
currentEnt.hasBeenSeen true;

    
anotherEnt.iEntity 6;
    
anotherEnt.hasBeenSeen false;

    
// save in array handle
    
PushArrayArray(g_hBlockedEntitiescurrentEnt);
    
PushArrayArray(g_hBlockedEntitiesanotherEnt);


    
// change value
    
currentEnt.iEntity anotherEnt.iEntity = -1;
    
currentEnt.hasBeenSeen anotherEnt.hasBeenSeen false;

    
// get values from handle
    
GetArrayArray(g_hBlockedEntities0anotherEnt);
    
GetArrayArray(g_hBlockedEntities1currentEnt);

    
PrintToServer("anotherEnt %i %s\ncurrentEnt %i %s\nsizeof currentEnt %i",
                                            
anotherEnt.iEntityanotherEnt.hasBeenSeen "TRUE":"FALSE",
                                            
currentEnt.iEntitycurrentEnt.hasBeenSeen "TRUE":"FALSE",
                                            
sizeof(currentEnt));



    
delete g_hBlockedEntities;

or
bad example
__________________
Do not Private Message @me

Last edited by Bacardi; 01-21-2024 at 04:11.
Bacardi is offline
High Cookie
New Member
Join Date: Jan 2024
Old 01-22-2024 , 04:24   Re: Beginner Needing Help - Updating Old Code.
Reply With Quote #3

Thanks for the detailed reply Bacardi.

I'm yet to have the time to try it again myself but your explination seems to make sense to me. I'll let you know how I go.

Cheers

Edit* Gave this a go, worked a treat: thanks Bacardi

Last edited by High Cookie; 01-25-2024 at 22:49.
High Cookie 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 06:12.


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