Skip to content

Commit

Permalink
v0.2, update to tModLoader 0.11.2.2, much smarter approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Jul 20, 2019
1 parent fd651e5 commit 2939e35
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 88 deletions.
65 changes: 40 additions & 25 deletions LargeWorldEnabler.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Reflection;
using Terraria;
using Terraria.Map;
using Terraria.ModLoader;

namespace LargeWorldEnabler
{
// TODO: Fix map drawing in tModLoader. (bounds, but maybe also something else apparently)
public class LargeWorldEnabler : Mod
{
public LargeWorldEnabler()
{
Properties = new ModProperties();
FieldInfo WorldGen_lastMaxTilesX;
FieldInfo WorldGen_lastMaxTilesY;

public override void Load() {
//if (ModLoader.version < new Version(0, 10))
//{
// throw new Exception("\nThis mod uses functionality only present in the latest tModLoader versions. Please update tModLoader to use this mod\n\n");
//}

On.Terraria.WorldGen.clearWorld += WorldGen_clearWorld;

WorldGen_lastMaxTilesX = typeof(WorldGen).GetField("lastMaxTilesX", BindingFlags.Static | BindingFlags.NonPublic);
WorldGen_lastMaxTilesY = typeof(WorldGen).GetField("lastMaxTilesY", BindingFlags.Static | BindingFlags.NonPublic);
}

public override void Load()
{
// Older versions don't have the correct variables.
if (ModLoader.version < new Version(0, 10))
{
throw new Exception("\nThis mod uses functionality only present in the latest tModLoader versions. Please update tModLoader to use this mod\n\n");
}
private void WorldGen_clearWorld(On.Terraria.WorldGen.orig_clearWorld orig) {
int lastMaxTilesX = (int)WorldGen_lastMaxTilesX.GetValue(null);
int lastMaxTilesY = (int)WorldGen_lastMaxTilesY.GetValue(null);

//8400 x 2400 -- Actual dimensions of tile array
Main.maxTilesX = 16800;
Main.maxTilesY = 4800;
// TODO: investigate cpu/ram trade-off for reducing this later when regular-sized worlds loaded.
if (Main.maxTilesX > 8400 && Main.maxTilesX > lastMaxTilesX || Main.maxTilesY > 2400 && Main.maxTilesY > lastMaxTilesY) {
// Goal: Increase limits, don't decrease anything lower than normal max for compatibility.

// Map render targets. -- ingame map number of images to write to. The textures themselves
Main.mapTargetX = 10; // change that 4 in vanilla to target-x
Main.mapTargetY = 4; // change that
Main.instance.mapTarget = new RenderTarget2D[Main.mapTargetX, Main.mapTargetY];
// TODO: dynamically change mapTargetX and Y to support any dimensions. (simple division.)
// Map render targets. -- ingame map number of images to write to. The textures themselves
Main.mapTargetX = 10; // change that 4 in vanilla to target-x
Main.mapTargetY = 4; // change that
Main.instance.mapTarget = new RenderTarget2D[Main.mapTargetX, Main.mapTargetY];

// Individual map tiles
Main.Map = new WorldMap(Main.maxTilesX, Main.maxTilesY);
int intendedMaxX = Math.Max(Main.maxTilesX + 1, 8401);
int intendedMaxY = Math.Max(Main.maxTilesY + 1, 2401);

// Space for more tiles -- Actual tiles
Main.tile = new Tile[Main.maxTilesX + 1, Main.maxTilesY + 1];
// Color for each tile
// Individual map tiles
Main.Map = new WorldMap(intendedMaxX, intendedMaxY);

Main.initMap = new bool[Main.mapTargetX, Main.mapTargetY];
Main.mapWasContentLost = new bool[Main.mapTargetX, Main.mapTargetY];
// Space for more tiles -- Actual tiles
Main.tile = new Tile[intendedMaxX, intendedMaxY];
// Color for each tile

Main.initMap = new bool[Main.mapTargetX, Main.mapTargetY];
Main.mapWasContentLost = new bool[Main.mapTargetX, Main.mapTargetY];
}
orig();

//8400 x 2400 -- Actual dimensions of tile array
//Main.maxTilesX = 16800;
//Main.maxTilesY = 4800;

// Initialized later, not needed.
//RemoteClient.TileSections = new bool[Main.maxTilesX / 200 + 1, Main.maxTilesY / 150 + 1];
Expand Down
67 changes: 8 additions & 59 deletions LargeWorldEnabler.csproj
Original file line number Diff line number Diff line change
@@ -1,64 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\references\tModLoader.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{79E45A3D-A6F7-4B9D-9B2C-D3ED099C2E2D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LargeWorldEnabler</RootNamespace>
<AssemblyName>LargeWorldEnabler</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFramework>net45</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="LargeWorldEnabler.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Modding\tModLoader\src\tModLoader\Terraria.csproj">
<Project>{3996d5fa-6e59-4fe4-9f2b-40eeef9645d5}</Project>
<Name>Terraria</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="build.txt" />
<Content Include="description.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
<Target Name="BuildMod" AfterTargets="Build">
<Exec Command="&quot;$(tMLBuildServerPath)&quot; -build $(ProjectDir) -eac $(TargetPath) -define $(DefineConstants) -unsafe $(AllowUnsafeBlocks)" />
</Target>
-->
</Project>
14 changes: 14 additions & 0 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"Terraria": {
"commandName": "Executable",
"executablePath": "$(tMLPath)",
"workingDirectory": "$(TerrariaSteamPath)"
},
"TerrariaServer": {
"commandName": "Executable",
"executablePath": "$(tMLServerPath)",
"workingDirectory": "$(TerrariaSteamPath)"
}
}
}
4 changes: 2 additions & 2 deletions build.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
author = jopojelly
version = 0.1.2
version = 0.2
displayName = Large World Enabler
homepage = http://forums.terraria.org/index.php?threads/large-world-enabler.47751/
hideCode = false
hideResources = false
includeSource = true
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, lib\*, .gitignore
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, *.config, .gitignore
2 changes: 0 additions & 2 deletions description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Note that with mods loaded, it may not be possible to load a world that large due to memory limits. I recommend a 16800x1200 or 16800x2400 world as worlds that are taller than Large worlds tend to be boring.

Generate a world to use with this mod using TerraCustom. TerraCustom will load tmodloader mods, so you don't have to worry about missing out on mod biomes. (http://forums.terraria.org/index.php?threads/terracustom-for-1-3.35346/)

This mod is also necessary if loading a world generated using Alternate Dimensions Mod (WIP) that is more than 8400 tiles in width.

0 comments on commit 2939e35

Please sign in to comment.