roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
709 stars 110 forks source link

Fix AddResource offset for Linux #479

Closed Yarukon closed 3 weeks ago

Yarukon commented 1 month ago

need those who use linux to test this to see if the crash still occur (i dont have linux enviroment to test this rn) how to test: try precache something and then change map

xen-000 commented 1 month ago

I believe the offset should be 0 on linux and 2 on windows, this is because the first 3 functions in IEntityResourceManifest are all overloads of AddResource:

class IEntityResourceManifest
{
public:
    virtual void AddResource(const char*) = 0;
    virtual void AddResource(const char*, void*) = 0;
    virtual void AddResource(const char*, void*, void*, void*) = 0;
    virtual void unk_04() = 0;
    virtual void unk_05() = 0;
    virtual void unk_06() = 0;
    virtual void unk_07() = 0;
    virtual void unk_08() = 0;
    virtual void unk_09() = 0;
    virtual void unk_10() = 0;
};

So what you want to use is the first one, or offset 0. But MSVC flips overload ordering so it becomes the third function, or offset 2.

Yarukon commented 1 month ago

I believe the offset should be 0 on linux and 2 on windows, this is because the first 3 functions in IEntityResourceManifest are all overloads of AddResource:

class IEntityResourceManifest
{
public:
  virtual void AddResource(const char*) = 0;
  virtual void AddResource(const char*, void*) = 0;
  virtual void AddResource(const char*, void*, void*, void*) = 0;
  virtual void unk_04() = 0;
  virtual void unk_05() = 0;
  virtual void unk_06() = 0;
  virtual void unk_07() = 0;
  virtual void unk_08() = 0;
  virtual void unk_09() = 0;
  virtual void unk_10() = 0;
};

So what you want to use is the first one, or offset 0. But MSVC flips overload ordering so it becomes the third function, or offset 2.

changed to 0

xLeviNx commented 1 month ago

Tested. This can be merged.

@roflmuffin