Skip to content

Conversation

ELDment
Copy link
Contributor

@ELDment ELDment commented Aug 28, 2025

When building a class in the C# layer, class_ptr would consistently receive an incorrect value, experience erroneous pointer dereferencing, or fail to update the class_name

https://discord.com/channels/1178027657594687608/1260707376923672577/1410251539347673289

When building a class in the C# layer, class_ptr would consistently receive an incorrect value, experience erroneous pointer dereferencing, or fail to update the class_name
@nicedayzhu
Copy link

Confirmed Pass!

Test code:

public Classes.CPlantedC4? GetPlantedC4()
 {
     var plantedC4 = Generic.FindEntitiesByClassname("planted_c4");
     if (plantedC4 == null)
     {
         Console.WriteLine($"GetPlantedC4: FindEntitiesByClassname returned null +++ ");
         return null;
     }

     if (plantedC4.Length == 0)
     {
         Console.WriteLine($"GetPlantedC4: No planted_c4 entities found +++ ");
         return null;
     }

     Console.WriteLine($"GetPlantedC4: Found {plantedC4.Length} planted_c4 entities ++++ ");

     var firstC4 = plantedC4.FirstOrDefault();
     if (firstC4 == null)
     {
         Console.WriteLine($"GetPlantedC4: FirstOrDefault returned null +++ ");
         return null;
     }
     // 直接传递 CEntityInstance,让构造函数处理转换
     var tmp = new Classes.CPlantedC4(firstC4);

     if (!tmp.IsValid())
     {
         Console.WriteLine($"tmp is InValid +++ ");
         return null;
     }

     Console.WriteLine($"tmp.TimerLength {tmp.TimerLength} +++ ");
     Console.WriteLine($"tmp.BombSite {tmp.BombSite} +++ ");
     return tmp;
 }

Result:
image

@skuzzis skuzzis merged commit d64242c into swiftly-solution:main Aug 28, 2025
@skuzzis
Copy link
Member

skuzzis commented Aug 28, 2025

Thanks for correcting this <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants