Skip to content

Commit

Permalink
Merge branch '1.4.4' of https://github.com/turtletowerz/tModLoader in…
Browse files Browse the repository at this point in the history
…to 1.4.4
  • Loading branch information
turtletowerz committed Jan 31, 2025
2 parents 8bce729 + 08a48d5 commit cfb33e6
Show file tree
Hide file tree
Showing 27 changed files with 181 additions and 73 deletions.
4 changes: 3 additions & 1 deletion ExampleMod/Content/NPCs/ExampleWorm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ExampleMod.Content.Items.Placeable.Banners;
using ExampleMod.Content.Items.Placeable.Banners;
using ExampleMod.NPCs;
using Microsoft.Xna.Framework;
using System.IO;
Expand Down Expand Up @@ -102,6 +102,7 @@ public override void SetStaticDefaults() {
Hide = true // Hides this NPC from the Bestiary, useful for multi-part NPCs whom you only want one entry.
};
NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value);
NPCID.Sets.RespawnEnemyID[NPC.type] = ModContent.NPCType<ExampleWormHead>();
}

public override void SetDefaults() {
Expand All @@ -124,6 +125,7 @@ public override void SetStaticDefaults() {
Hide = true // Hides this NPC from the Bestiary, useful for multi-part NPCs whom you only want one entry.
};
NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, value);
NPCID.Sets.RespawnEnemyID[NPC.type] = ModContent.NPCType<ExampleWormHead>();
}

public override void SetDefaults() {
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Content/NPCs/MinionBoss/MinionBossMinion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void SetStaticDefaults() {

// By default enemies gain health and attack if hardmode is reached. this NPC should not be affected by that
NPCID.Sets.DontDoHardmodeScaling[Type] = true;
// Enemies can pick up coins, let's prevent it for this NPC
// Enemies can pick up coins and be respawned automatically, let's prevent it for this NPC since we don't want this enemy to respawn outside of a boss fight.
NPCID.Sets.CantTakeLunchMoney[Type] = true;
// Automatically group with other bosses
NPCID.Sets.BossBestiaryPriority.Add(Type);
Expand Down
6 changes: 4 additions & 2 deletions patches/tModLoader/Terraria/ID/NPCID.cs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
public static List<int> GoldCrittersCollection = new List<int> {
443,
442,
@@ -4933,8 +_,24 @@
@@ -4933,8 +_,26 @@
448,
539
};
Expand All @@ -241,14 +241,16 @@
+
+ /// <summary>
+ /// If <see langword="true"/> for a given NPC type (<see cref="NPC.type"/>), then that NPC cannot pick up dropped coins in Expert Mode.
+ /// <br/> Defaults to <see langword="false"/>.
+ /// <para/> Vanilla entries include mainly boss summons and other NPC that shouldn't be able to respawn naturally. See also <see cref="RespawnEnemyID"/>.
+ /// <para/> Defaults to <see langword="false"/>.
+ /// </summary>
public static bool[] CantTakeLunchMoney = Factory.CreateBoolSet(394, 393, 392, 492, 491, 662, 384, 478, 535, 658, 659, 660, 128, 131, 129, 130, 139, 267, 247, 248, 246, 249, 245, 409, 410, 397, 396, 401, 400, 440, 68, 534);
+
+ /// <summary>
+ /// Associates an NPC type (<see cref="NPC.type"/>) with the NPC type it respawns as from the coin loss system (<see cref="GameContent.CoinLossRevengeSystem"/>).
+ /// <br/> If an NPC type is not a key in this dictionary, then that NPC respawns as itself.
+ /// <br/> If the value for an NPC type is <c>0</c>, then that NPC won't be cached (<see cref="GameContent.CoinLossRevengeSystem.CacheEnemy(NPC)"/>).
+ /// <para/> Some vanilla entries contain 0 values for special enemies that shouldn't respawn and other entries contain values indicating the "head" NPC of worm enemies to allow them to spawn the worm correctly. (Worm enemies currently don't work with the coin loss revenge system, however.) See also <see cref="CantTakeLunchMoney"/>.
+ /// </summary>
public static Dictionary<int, int> RespawnEnemyID = new Dictionary<int, int> {
{ 492, 0 },
Expand Down
16 changes: 12 additions & 4 deletions patches/tModLoader/Terraria/Item.cs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1809,11 +1809,17 @@
{
useStyle = 1;
useTurn = true;
@@ -47088,6 +_,22 @@
@@ -47088,6 +_,28 @@
SetDefaults(Type, noMatCheck: false, null);
}

+ // Added by TML.
+ /// <summary>
+ /// Call in <see cref="ModItem.SetDefaults"/> to clone all the default item property values of an existing item. This is useful for prototyping or making a variant of an existing item. Note that other changes made to the cloned item, such as if another mod changes a weapon's damage, will be applied when using this approach. This may or may not be desired.
+ /// <para/> When using this method make sure that any additional changes to item properties are on lines after this method is called, otherwise they will be overwritten. Some values cloned by this method might be undesired, such as equipment slot values like shoeSlot. <see href="https://github.com/tModLoader/tModLoader/blob/1.4.4/ExampleMod/Content/Items/Accessories/WaspNest.cs#L51">WaspNest.cs</see> shows how to cache and restore those values.
+ /// <para/> This will only clone the values, any additional logic such as shoot accuracy, recipes, accessory effects, use item logic, etc. will not be copied. The <see href="https://github.com/tModLoader/tModLoader/wiki/Advanced-Vanilla-Code-Adaption">Vanilla Code Adaption wiki page</see> teaches how to make a complete clone of an existing item.
+ /// </summary>
+ /// <param name="TypeToClone"></param>
+ public void CloneDefaults(int TypeToClone)
+ {
+ int originalType = type;
Expand Down Expand Up @@ -1893,7 +1899,7 @@
if (type == 5437)
SetDefaults(5358);
}
@@ -47318,14 +_,33 @@
@@ -47318,14 +_,34 @@
{
tooltipContext = -1;
BestiaryNotes = null;
Expand All @@ -1914,6 +1920,7 @@
+ ChangePlayerDirectionOnShoot = true;
+ ArmorPenetration = 0;
+
+ _nameOverride = null; // Added by TML.
sentry = false;
hasVanityEffects = false;
DD2Summon = false;
Expand Down Expand Up @@ -2333,12 +2340,13 @@
{
if (netID == compareItem.netID && stack == compareItem.stack)
return prefix != compareItem.prefix;
@@ -49285,11 +_,18 @@
@@ -49285,11 +_,19 @@
return true;
}

+ /// <summary>
+ /// Overrides the value of <see cref="Name"/>.
+ /// Overrides the value of <see cref="Name"/> for this Item instance. This is used mainly to change the name shown on the item tooltip for recipe group ingredients to "Any RecipeGroupItemNameHere".
+ /// <para/> This does not change the actual name of this item when shown elsewhere as text, for example, so it is not a suitable way to permanently change an item name. To do that a <see href="https://github.com/tModLoader/tModLoader/wiki/Localization#overwriting-existing-terraria-keys">localization file entry</see> should be used instead.
+ /// </summary>
+ /// <param name="name">The new name of this <see cref="Item"/>.</param>
public void SetNameOverride(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(siehe {0} für weitere Informationen)",
"ShopOverflow": "Nicht alle Gegenstände passen in den Shop!",
"PlayerSaveFail": "Beim Speichern des Spielers ist ein Fehler aufgetreten",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Logs öffnen",
"OpenWebHelp": "Webhilfe öffnen",
"SkipToMainMenu": "Das Laden von Mods überspringen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(see {0} for full trace)",
"ShopOverflow": "Not all items could fit in the shop!",
"PlayerSaveFail": "An error occurred while saving the player",
"BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Open Logs",
"OpenWebHelp": "Open Web Help",
"SkipToMainMenu": "Skip Loading Mods",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(abre {0} para ver el registro completo)",
"ShopOverflow": "¡No caben todos los objetos en la tienda!",
"PlayerSaveFail": "Se produjo un error al guardar el jugador",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Abrir registros",
"OpenWebHelp": "Abrir página de ayuda en el navegador",
"SkipToMainMenu": "Omitir carga de mods",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(Voir {0} pour plus de détails)",
// "ShopOverflow": "Not all items could fit in the shop!",
// "PlayerSaveFail": "An error occurred while saving the player",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Ouvrir les Registres",
"OpenWebHelp": "Ouvrir l'Aide Internet",
"SkipToMainMenu": "Sauter le chargement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
// "RuntimeErrorSeeLogsForFullTrace": "(see {0} for full trace)",
// "ShopOverflow": "Not all items could fit in the shop!",
// "PlayerSaveFail": "An error occurred while saving the player",
// "BackingUpPlayerFile": "Backing up player file",
// "OpenLogs": "Open Logs",
// "OpenWebHelp": "Open Web Help",
// "SkipToMainMenu": "Skip Loading Mods",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(zobacz {0}, aby uzyskać więcej informacji)",
"ShopOverflow": "Nie wszystkie przedmioty zmieściły się w sklepie!",
"PlayerSaveFail": "Wystąpił błąd podczas zapisywania gracza",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Otwórz logi",
"OpenWebHelp": "Otwórz pomoc",
"SkipToMainMenu": "Pomiń Ładowanie Modów",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(veja {0} para o rastreamento completo)",
"ShopOverflow": "Não foi possível encaixar todos os itens na loja!",
"PlayerSaveFail": "Ocorreu um erro ao salvar o jogador",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Abrir Registros",
"OpenWebHelp": "Abrir Ajuda na Web",
"SkipToMainMenu": "Pular o Carregamento de Mods",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@
"LoadErrorDotNet45Required": "Для использования модов требуется .NET Framework 4.5 или новее. Пожалуйста, скачайте и установите последнюю версию .NET Framework",
"LoadErrorDependencyMissing": "Отсутствует мод: Для правильной работы {1} требуется {0}",
"LoadErrorErrorReadingModFile": "Ошибка при чтении файла мода {0}",
"LoadErrorHashMismatchCorrupted": "Несоответствие хэшей, массив данных был изменён или повреждён",
// "LoadErrorHashMismatchCorruptedWithModName": "Unable to verify integrity of {0}: hash mismatch; data blob has been modified or corrupted",
"LoadErrorHashMismatchCorrupted": "Несоответствие хэша, массив данных был изменён или повреждён",
"LoadErrorHashMismatchCorruptedWithModName": "Не удалось проверить целостность {0}: несоответствие хэша; данные были изменены или повреждены",
"LoadErrorDependencyVersionTooLow": "Для {0} необходим {2} версии {1} или выше, но у вас установлена версия {3}.",
"LoadErrorMajorVersionMismatch": "{0} поддерживает {2} версии {1}, но у вас установлено новое крупное обновление с версией ({3}), которая может быть несовместима. {0} необходимо обновить.",
"LoadErrorRecentlyBuiltLocalModWithLowerVersionWorkshop": "Мод {0} версии {1} был недавно собран, но не был загружён, так как подписанная версия из Мастерской ({2}) является более новой.\nЛибо обновите файл build.txt и пересоберите мод, либо временно отпишитесь от мода.",
Expand Down Expand Up @@ -240,6 +240,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(смотрите {0} для получения полной трассировки стека)",
"ShopOverflow": "Не все товары поместились в магазине!",
"PlayerSaveFail": "Произошла ошибка при сохранении персонажа",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "Открыть лог-папку",
"OpenWebHelp": "Открыть веб-справку",
"SkipToMainMenu": "Пропустить загрузку модов",
Expand Down Expand Up @@ -301,7 +302,7 @@
"MPServerModsCantDownloadChangeSettingsHint": "Вам нужно изменить свои настройки или получить моды у владельца сервера.",
"MPShowServerConsoleYes": "Отображать консоль сервера: Да",
"MPShowServerConsoleNo": "Отображать консоль сервера: Нет",
"MPErrorModHashMismatch": "Несоответствие хэшей",
"MPErrorModHashMismatch": "Несоответствие хэша",
"MPErrorModNotSigned": "Мод не был подписан «Браузером модов»",
"MPErrorModDownloadError": "Произошла ошибка во время скачивания {0}",
"MPPacketTooLarge": "Сетевой пакет слишком большой - {0} > {1}",
Expand All @@ -321,7 +322,7 @@
"ReloadRequiredExplanationDisable": "[c/{0}:Отключение]",
"ReloadRequiredExplanationConfigChanged": "Временное [c/{0}:изменение конфигурации]",
"ReloadRequiredExplanationConfigChangedRestore": "[c/{0}:Восстановление конфигурации]",
// "ReloadRequiredHostAndPlayModWasDisabledHint": "It is possible that a mod you had previously enabled has errors when run on the server and has been automatically disabled. Check server.log to investigate these issues. Click here to open the FAQ for this issue.",
"ReloadRequiredHostAndPlayModWasDisabledHint": "Возможно, один из ранее включённых модов содержит ошибки, возникающие при работе на сервере, и был автоматически отключён. Проверьте файл server.log для подробного изучения проблемы. Нажмите здесь, чтобы открыть FAQ по этой проблеме.",

// UIAsyncList
"ALLoading": "Загрузка...",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"RuntimeErrorSeeLogsForFullTrace": "(请参阅 {0} 以获取完整调用堆栈)",
"ShopOverflow": "物品太多,塞不进商店里 :(",
"PlayerSaveFail": "保存人物时发生错误",
// "BackingUpPlayerFile": "Backing up player file",
"OpenLogs": "打开日志",
"OpenWebHelp": "打开网页帮助",
"SkipToMainMenu": "跳过加载模组",
Expand Down
5 changes: 3 additions & 2 deletions patches/tModLoader/Terraria/MessageBuffer.cs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
item4.position = position3;
item4.velocity = velocity3;
item4.active = true;
@@ -1419,11 +_,15 @@
@@ -1419,11 +_,16 @@
if (num158 == 668)
NPC.deerclopsBoss = num155;

Expand All @@ -278,7 +278,8 @@
nPC5.releaseOwner = reader.ReadByte();

+ // Extra AI is read into a temporary buffer for parity with ProjectileLoader code, and to avoid exceptions causing underreads.
+ NPCLoader.ReceiveExtraAI(nPC5, NPCLoader.ReadExtraAI(reader));
+ if (bitsByte12[3])
+ NPCLoader.ReceiveExtraAI(nPC5, NPCLoader.ReadExtraAI(reader));
+
break;
}
Expand Down
3 changes: 3 additions & 0 deletions patches/tModLoader/Terraria/ModLoader/Core/BuildProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ internal static BuildProperties ReadBuildFile(string modDir)
if (refs.Count != refs.Distinct().Count())
throw new Exception("Duplicate mod/weak reference");

if (properties.dllReferences.Union(properties.modReferences.Select(x => x.mod)).Any())
throw new Exception("dllReferences contains duplicate of modReferences");

//add (mod|weak)References that are not in sortBefore to sortAfter
properties.sortAfter = properties.RefNames(true).Where(dep => !properties.sortBefore.Contains(dep))
.Concat(properties.sortAfter).Distinct().ToArray();
Expand Down
41 changes: 35 additions & 6 deletions patches/tModLoader/Terraria/ModLoader/Engine/LoggingHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,52 @@ private static void HookProcessStart()
private delegate void hook_StackTrace_CaptureStackTrace(orig_StackTrace_CaptureStackTrace orig, StackTrace self, int skipFrames, bool fNeedFileInfo, Exception e);

private static void Hook_StackTrace_CaptureStackTrace(orig_StackTrace_CaptureStackTrace orig, StackTrace self, int skipFrames, bool fNeedFileInfo, Exception e) {
// avoid including the hook frames in manually captured stack traces. Note that 2 frames are from the hook, and the System.Diagnostics frame is normally trimmed by CalculateFramesToSkip in StackTrace.CoreCLR.cs
//
// avoid including the hook frames in manually captured stack traces. Note that 3 frames are from the hook, and the System.Diagnostics frame is normally trimmed by CalculateFramesToSkip in StackTrace.CoreCLR.cs
// The Hook_StackTrace_CaptureStackTrace frame is only present in DEBUG

// at Terraria.ModLoader.Engine.LoggingHooks.Hook_StackTrace_CaptureStackTrace(orig_StackTrace_CaptureStackTrace orig, StackTrace self, Int32 skipFrames, Boolean fNeedFileInfo, Exception e) in tModLoader\Terraria\ModLoader\Engine\LoggingHooks.cs:line 65
// at Hook<System.Void Terraria.ModLoader.Engine.LoggingHooks::Hook_StackTrace_CaptureStackTrace(Terraria.ModLoader.Engine.LoggingHooks+orig_StackTrace_CaptureStackTrace,System.Diagnostics.StackTrace,System.Int32,System.Boolean,System.Exception)>(StackTrace , Int32 , Boolean , Exception )
// at SyncProxy<System.Void System.Diagnostics.StackTrace:CaptureStackTrace(System.Int32, System.Boolean, System.Exception) > (StackTrace, Int32, Boolean, Exception)
// at System.Diagnostics.StackTrace..ctor(Boolean fNeedFileInfo)
int skipHookFrames = e == null ? 3 : 0;
// at SyncProxy<System.Void System.Diagnostics.StackTrace:CaptureStackTrace(System.Int32, System.Boolean, System.Exception)>(StackTrace , Int32 , Boolean , Exception )
// at System.Diagnostics.StackTrace..ctor(Int32 skipFrames, Boolean fNeedFileInfo)

if (e == null) {
#if DEBUG
skipFrames += 4;
#else
skipFrames += 3;
#endif
}

orig(self, skipFrames + skipHookFrames, fNeedFileInfo, e);
orig(self, skipFrames, fNeedFileInfo, e);

if (fNeedFileInfo)
Logging.PrettifyStackTraceSources(self.GetFrames());
}

private delegate void orig_GetSourceLineInfo(object self, Assembly assembly, string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, bool isFileLayout, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string? sourceFile, out int sourceLine, out int sourceColumn);
private delegate void hook_GetSourceLineInfo(orig_GetSourceLineInfo orig, object self, Assembly assembly, string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, bool isFileLayout, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string? sourceFile, out int sourceLine, out int sourceColumn);
private static void Hook_GetSourceLineInfo(orig_GetSourceLineInfo orig, object self, Assembly assembly, string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, bool isFileLayout, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string? sourceFile, out int sourceLine, out int sourceColumn)
{
try {
using var _ = new Logging.QuietExceptionHandle();
orig(self, assembly, assemblyPath, loadedPeAddress, loadedPeSize, isFileLayout, inMemoryPdbAddress, inMemoryPdbSize, methodToken, ilOffset, out sourceFile, out sourceLine, out sourceColumn);
}
catch (BadImageFormatException) when (assembly.FullName.StartsWith("MonoMod.Utils")) {
sourceFile = null;
sourceLine = 0;
sourceColumn = 0;
}
}


private static Hook stackTrace_CaptureStackTrace;
private static Hook stackTraceSymbols_GetSourceLineInfo;
private static void PrettifyStackTraceSources() {
stackTrace_CaptureStackTrace = new Hook(typeof(StackTrace).GetMethod("CaptureStackTrace", BindingFlags.NonPublic | BindingFlags.Instance)!,
new hook_StackTrace_CaptureStackTrace(Hook_StackTrace_CaptureStackTrace));

stackTraceSymbols_GetSourceLineInfo = new Hook(Assembly.Load("System.Diagnostics.StackTrace").GetType("System.Diagnostics.StackTraceSymbols").GetMethod("GetSourceLineInfo", BindingFlags.NonPublic | BindingFlags.Instance)!,
new hook_GetSourceLineInfo(Hook_GetSourceLineInfo));
}

private delegate ValueTask<HttpResponseMessage> orig_SendAsyncCore(object self, HttpRequestMessage request, Uri? proxyUri, bool async, bool doRequestAuth, bool isProxyConnect, CancellationToken cancellationToken);
Expand Down
Loading

0 comments on commit cfb33e6

Please sign in to comment.