Skip to content

Commit 72ad245

Browse files
committed
More shims and corrections
1 parent 89c4513 commit 72ad245

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

OTAPI.Scripts/Patches/PatchNpcStrikeArgs.Server.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,18 @@ static void PatchNpcStrikeArgs(ModFwModder modder)
7373
switch (methodName.Replace(HookEmitter.HookMethodNamePrefix, ""))
7474
{
7575
case "MessageBuffer.GetData":
76+
// order matters with this logic...
77+
var hasWhoAmI = instr.Previous.OpCode == OpCodes.Ldfld &&
78+
instr.Previous.Operand is FieldReference fieldReference &&
79+
fieldReference.Name == "whoAmI";
80+
7681
var playerRef = Instruction.Create(OpCodes.Ldsfld, modder.Module.ImportReference(modder.GetFieldDefinition(() => Terraria.Main.player)));
7782
body.GetILProcessor().InsertBefore(instr, playerRef);
7883
body.GetILProcessor().InsertBefore(instr,
7984
new { OpCodes.Ldarg_0 },
8085
new { OpCodes.Ldfld, Operand = modder.Module.ImportReference(modder.GetFieldDefinition(() => (new Terraria.MessageBuffer()).whoAmI)) },
8186
new { OpCodes.Ldelem_Ref }
82-
);
83-
84-
var hasWhoAmI = instr.Previous.OpCode == OpCodes.Ldfld &&
85-
instr.Previous.Operand is FieldReference fieldReference &&
86-
fieldReference.Name == "whoAmI";
87+
);
8788
if (hasWhoAmI) { // 145+
8889
// rewire the branching
8990
var brs = instr.Previous(x => x.OpCode == OpCodes.Br_S);

OTAPI.Scripts/Shims/Xna/Graphics/GraphicsResource.Server.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ public void Dispose()
3333

3434
public bool IsDisposed { get; set; }
3535
public string Name { get; set; }
36+
public object Tag { get; set; }
3637
}
3738
}

OTAPI.Scripts/Shims/Xna/Graphics/Texture2D.Server.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
1616
You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
18-
*/
19-
#pragma warning disable CS0436 // Type conflicts with imported type
20-
18+
*/
19+
#pragma warning disable CS0436 // Type conflicts with imported type
20+
2121
using System;
2222
using System.Runtime.InteropServices;
2323

@@ -35,6 +35,8 @@ public class Texture2D : Texture
3535
public int Height { get; set; }
3636

3737
public int Width { get; set; }
38+
39+
public Rectangle Bounds => new (0, 0, Width, Height);
3840

3941
public Texture2D (
4042
GraphicsDevice graphicsDevice,

OTAPI.Scripts/Shims/Xna/Input/KeyboardState.Server.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public bool IsKeyDown(Keys key)
2929
return false;
3030
}
3131

32+
public bool IsKeyUp(Keys key)
33+
{
34+
return false;
35+
}
36+
3237
public Keys[] GetPressedKeys() { return Empty; }
3338
}
3439
}

0 commit comments

Comments
 (0)