mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-19 19:06:45 -05:00
Replaced all system exceptions with OpenDiablo2Exception
This commit is contained in:
parent
0259408601
commit
86547875fd
@ -46,7 +46,7 @@ namespace OpenDiablo2.Common.Enums
|
||||
Act5_BaalEntrance = 120,
|
||||
}
|
||||
|
||||
public class ELevelIdHelper
|
||||
public static class ELevelIdHelper
|
||||
{
|
||||
public static string GenerateEnum(List<LevelPreset> levelPresets)
|
||||
{
|
||||
|
32
OpenDiablo2.Common/Exceptions/OpenDiablo2Exception.cs
Normal file
32
OpenDiablo2.Common/Exceptions/OpenDiablo2Exception.cs
Normal file
@ -0,0 +1,32 @@
|
||||
/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenDiablo2.Common.Exceptions
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public class OpenDiablo2Exception : Exception
|
||||
{
|
||||
public OpenDiablo2Exception() { }
|
||||
public OpenDiablo2Exception(string message) : base(message) { }
|
||||
public OpenDiablo2Exception(string message, Exception inner) : base(message, inner) { }
|
||||
protected OpenDiablo2Exception(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
@ -115,7 +116,7 @@ namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
var header = Encoding.ASCII.GetString(br.ReadBytes(4));
|
||||
if (header != HEADER_SIGNATURE)
|
||||
throw new ApplicationException($"Unknown header signature '{header}' detected while processing '{Path}'!");
|
||||
throw new OpenDiablo2Exception($"Unknown header signature '{header}' detected while processing '{Path}'!");
|
||||
|
||||
ParseMPQHeader(br);
|
||||
}
|
||||
@ -198,10 +199,10 @@ namespace OpenDiablo2.Common.Models
|
||||
};
|
||||
|
||||
if (FormatVersion != eMPQFormatVersion.Format1)
|
||||
throw new ApplicationException($"Unsupported MPQ format version of {Header.FormatVersion} detected for '{Path}'!");
|
||||
throw new OpenDiablo2Exception($"Unsupported MPQ format version of {Header.FormatVersion} detected for '{Path}'!");
|
||||
|
||||
if (br.BaseStream.Position != Header.HeaderSize)
|
||||
throw new ApplicationException($"Invalid header size detected for '{Path}'. Expected to be at offset {Header.HeaderSize} but we are at offset {br.BaseStream.Position} instead!");
|
||||
throw new OpenDiablo2Exception($"Invalid header size detected for '{Path}'. Expected to be at offset {Header.HeaderSize} but we are at offset {br.BaseStream.Position} instead!");
|
||||
|
||||
br.BaseStream.Seek(Header.BlockTablePos, SeekOrigin.Begin);
|
||||
|
||||
@ -254,7 +255,7 @@ namespace OpenDiablo2.Common.Models
|
||||
private static UInt32 HashString(string inputString, UInt32 hashType)
|
||||
{
|
||||
if (hashType > MPQ_HASH_FILE_KEY)
|
||||
throw new ApplicationException($"Unknown hash type {hashType} for input string {inputString}");
|
||||
throw new OpenDiablo2Exception($"Unknown hash type {hashType} for input string {inputString}");
|
||||
|
||||
UInt32 seed1 = 0x7FED7FED;
|
||||
UInt32 seed2 = 0xEEEEEEEE;
|
||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
@ -198,7 +199,7 @@ namespace OpenDiablo2.Common.Models
|
||||
};
|
||||
|
||||
if (OptionalDataBits > 0)
|
||||
throw new ApplicationException("Optional bits in DCC data is not currently supported.");
|
||||
throw new OpenDiablo2Exception("Optional bits in DCC data is not currently supported.");
|
||||
|
||||
if ((CompressionFlags & 0x2) > 0)
|
||||
EqualCellsBitstreamSize = (int)bm.GetBits(20);
|
||||
@ -259,25 +260,25 @@ namespace OpenDiablo2.Common.Models
|
||||
FillPixelBuffer(pixelCodeandDisplacement, equalCellsBitstream, pixelMaskBitstream, encodingTypeBitsream, rawPixelCodesBitstream);
|
||||
|
||||
// Generate the actual frame pixel data
|
||||
GenerateFrames(file, pixelCodeandDisplacement);
|
||||
GenerateFrames(pixelCodeandDisplacement);
|
||||
|
||||
// Verify that everything we expected to read was actually read (sanity check)...
|
||||
if (equalCellsBitstream.BitsRead != EqualCellsBitstreamSize)
|
||||
throw new ApplicationException("Did not read the correct number of bits!");
|
||||
throw new OpenDiablo2Exception("Did not read the correct number of bits!");
|
||||
|
||||
if (pixelMaskBitstream.BitsRead != PixelMaskBitstreamSize)
|
||||
throw new ApplicationException("Did not read the correct number of bits!");
|
||||
throw new OpenDiablo2Exception("Did not read the correct number of bits!");
|
||||
|
||||
if (encodingTypeBitsream.BitsRead != EncodingTypeBitsreamSize)
|
||||
throw new ApplicationException("Did not read the correct number of bits!");
|
||||
throw new OpenDiablo2Exception("Did not read the correct number of bits!");
|
||||
|
||||
if (rawPixelCodesBitstream.BitsRead != RawPixelCodesBitstreamSize)
|
||||
throw new ApplicationException("Did not read the correct number of bits!");
|
||||
throw new OpenDiablo2Exception("Did not read the correct number of bits!");
|
||||
|
||||
bm.SkipBits(pixelCodeandDisplacement.BitsRead);
|
||||
}
|
||||
|
||||
private void GenerateFrames(MPQDCC file, BitMuncher pcd)
|
||||
private void GenerateFrames(BitMuncher pcd)
|
||||
{
|
||||
var pbIdx = 0;
|
||||
|
||||
@ -552,14 +553,14 @@ namespace OpenDiablo2.Common.Models
|
||||
var bm = new BitMuncher(data);
|
||||
Signature = bm.GetByte();
|
||||
if (Signature != 0x74)
|
||||
throw new ApplicationException("Signature expected to be 0x74 but it is not.");
|
||||
throw new OpenDiablo2Exception("Signature expected to be 0x74 but it is not.");
|
||||
|
||||
Version = bm.GetByte();
|
||||
NumberOfDirections = bm.GetByte();
|
||||
FramesPerDirection = bm.GetInt32();
|
||||
|
||||
if (bm.GetInt32() != 1)
|
||||
throw new ApplicationException("This value isn't 1. It has to be 1.");
|
||||
throw new OpenDiablo2Exception("This value isn't 1. It has to be 1.");
|
||||
|
||||
var totalSizeCoded = bm.GetInt32();
|
||||
var directionOffsets = new int[NumberOfDirections];
|
||||
|
@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
@ -136,7 +137,7 @@ namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
// 3D isometric block
|
||||
if (block.Length != 256)
|
||||
throw new ApplicationException($"Expected exactly 256 bytes of data, but got {block.Length} instead!");
|
||||
throw new OpenDiablo2Exception($"Expected exactly 256 bytes of data, but got {block.Length} instead!");
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
@ -19,6 +19,7 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
@ -37,7 +38,7 @@ namespace OpenDiablo2.Common.Models
|
||||
var br = new BinaryReader(tableStream);
|
||||
var wooCheck = Encoding.UTF8.GetString(br.ReadBytes(4));
|
||||
if (wooCheck != "Woo!")
|
||||
throw new ApplicationException("Error loading font. Missing the Woo!");
|
||||
throw new OpenDiablo2Exception("Error loading font. Missing the Woo!");
|
||||
br.ReadBytes(8);
|
||||
|
||||
while (tableStream.Position < tableStream.Length)
|
||||
|
@ -29,6 +29,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
@ -265,7 +266,7 @@ namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
int bit = input.ReadBits(1);
|
||||
if (bit == -1)
|
||||
throw new Exception("Unexpected end of file");
|
||||
throw new OpenDiablo2Exception("Unexpected end of file");
|
||||
|
||||
node = bit == 0 ? node.Child0 : node.Child1;
|
||||
}
|
||||
@ -384,6 +385,9 @@ namespace OpenDiablo2.Common.Models
|
||||
current.Next.Prev = current.Prev;
|
||||
|
||||
// insert current after prev
|
||||
if (prev == null)
|
||||
throw new OpenDiablo2Exception("Previous frame not defined!");
|
||||
|
||||
LinkedNode temp = prev.Next;
|
||||
current.Next = temp;
|
||||
current.Prev = prev;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -53,9 +54,9 @@ namespace OpenDiablo2.Common.Models
|
||||
MPQ.DecryptBlock(blockPositions, blockRecord.EncryptionSeed - 1);
|
||||
|
||||
if (blockPositions[0] != blockpossize)
|
||||
throw new ApplicationException("Decryption failed");
|
||||
throw new OpenDiablo2Exception("Decryption failed");
|
||||
if (blockPositions[1] > blockSize + blockpossize)
|
||||
throw new ApplicationException("Decryption failed");
|
||||
throw new OpenDiablo2Exception("Decryption failed");
|
||||
}
|
||||
|
||||
}
|
||||
@ -120,7 +121,7 @@ namespace OpenDiablo2.Common.Models
|
||||
mpq.fileStream.Seek(mpq.Header.HeaderSize + blockRecord.BlockOffset, SeekOrigin.Begin);
|
||||
int read = mpq.fileStream.Read(filedata, 0, filedata.Length);
|
||||
if (read != filedata.Length)
|
||||
throw new ApplicationException("Insufficient data or invalid data length");
|
||||
throw new OpenDiablo2Exception("Insufficient data or invalid data length");
|
||||
}
|
||||
|
||||
if (blockSize == blockRecord.FileSize)
|
||||
@ -204,13 +205,13 @@ namespace OpenDiablo2.Common.Models
|
||||
mpq.fileStream.Seek(offset, SeekOrigin.Begin);
|
||||
int read = mpq.fileStream.Read(data, 0, toread);
|
||||
if (read != toread)
|
||||
throw new ApplicationException("Insufficient data or invalid data length");
|
||||
throw new OpenDiablo2Exception("Insufficient data or invalid data length");
|
||||
}
|
||||
|
||||
if (blockRecord.IsEncrypted && blockRecord.FileSize > 3)
|
||||
{
|
||||
if (blockRecord.EncryptionSeed == 0)
|
||||
throw new ApplicationException("Unable to determine encryption key");
|
||||
throw new OpenDiablo2Exception("Unable to determine encryption key");
|
||||
|
||||
encryptionseed = (uint)(blockIndex + blockRecord.EncryptionSeed);
|
||||
MPQ.DecryptBlock(data, encryptionseed);
|
||||
@ -250,14 +251,14 @@ namespace OpenDiablo2.Common.Models
|
||||
return MpqWavCompression.Decompress(sinput, 1);
|
||||
|
||||
case 0x12:
|
||||
throw new ApplicationException("LZMA compression is not yet supported");
|
||||
throw new OpenDiablo2Exception("LZMA compression is not yet supported");
|
||||
// Combos
|
||||
case 0x22:
|
||||
// TODO: sparse then zlib
|
||||
throw new ApplicationException("Sparse compression + Deflate compression is not yet supported");
|
||||
throw new OpenDiablo2Exception("Sparse compression + Deflate compression is not yet supported");
|
||||
case 0x30:
|
||||
// TODO: sparse then bzip2
|
||||
throw new ApplicationException("Sparse compression + BZip2 compression is not yet supported");
|
||||
throw new OpenDiablo2Exception("Sparse compression + BZip2 compression is not yet supported");
|
||||
case 0x41:
|
||||
sinput = MpqHuffman.Decompress(sinput);
|
||||
return MpqWavCompression.Decompress(sinput, 1);
|
||||
@ -275,7 +276,7 @@ namespace OpenDiablo2.Common.Models
|
||||
return MpqWavCompression.Decompress(new MemoryStream(result), 2);
|
||||
}
|
||||
default:
|
||||
throw new ApplicationException("Compression is not yet supported: 0x" + comptype.ToString("X"));
|
||||
throw new OpenDiablo2Exception("Compression is not yet supported: 0x" + comptype.ToString("X"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces.Mobs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -57,7 +58,7 @@ namespace OpenDiablo2.Common.Models.Mobs
|
||||
{
|
||||
if (!long.TryParse(data[o][i], out long exp))
|
||||
{
|
||||
throw new Exception("Could not parse experience number '" + data[o][i] + "'.");
|
||||
throw new OpenDiablo2Exception("Could not parse experience number '" + data[o][i] + "'.");
|
||||
}
|
||||
expperlevel.Add(exp);
|
||||
}
|
||||
|
@ -80,6 +80,7 @@
|
||||
<Compile Include="Enums\Mobs\eDamageTypes.cs" />
|
||||
<Compile Include="Enums\Mobs\eMobFlags.cs" />
|
||||
<Compile Include="Enums\Mobs\eStatModifierType.cs" />
|
||||
<Compile Include="Exceptions\OpenDiablo2Exception.cs" />
|
||||
<Compile Include="Interfaces\Drawing\ICharacterRenderer.cs" />
|
||||
<Compile Include="Interfaces\ICache.cs" />
|
||||
<Compile Include="Interfaces\IItemManager.cs" />
|
||||
|
@ -3,7 +3,7 @@ using System.Text;
|
||||
|
||||
namespace OpenDiablo2.Common
|
||||
{
|
||||
public class StringUtils
|
||||
public static class StringUtils
|
||||
{
|
||||
public static List<string> SplitIntoLinesWithMaxWidth(string fullSentence, int maxChars)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.Core.Map_Engine;
|
||||
@ -210,7 +211,7 @@ namespace OpenDiablo2.Core.GameState_
|
||||
.Where(x => x != null);
|
||||
|
||||
default:
|
||||
throw new ApplicationException("Unknown render cell type!");
|
||||
throw new OpenDiablo2Exception("Unknown render cell type!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +354,7 @@ namespace OpenDiablo2.Core.GameState_
|
||||
{
|
||||
#if DEBUG
|
||||
if (!tiles.All(x => x.Animated))
|
||||
throw new ApplicationException("Some tiles are animated and some aren't...");
|
||||
throw new OpenDiablo2Exception("Some tiles are animated and some aren't...");
|
||||
#endif
|
||||
var frameIndex = (int)Math.Floor(tiles.Count() * animationTime);
|
||||
tile = tiles.ElementAt(frameIndex);
|
||||
@ -377,7 +378,7 @@ namespace OpenDiablo2.Core.GameState_
|
||||
}
|
||||
|
||||
if (tile.Animated)
|
||||
throw new ApplicationException("Why are we randomly finding an animated tile? Something's wrong here.");
|
||||
throw new OpenDiablo2Exception("Why are we randomly finding an animated tile? Something's wrong here.");
|
||||
}
|
||||
else tile = tiles.First();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces.Mobs;
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
|
||||
@ -35,7 +36,7 @@ namespace OpenDiablo2.Core.GameState_
|
||||
{
|
||||
Mobs.Add(mob);
|
||||
if (IdsUsed.Contains(mob.Id))
|
||||
throw new ApplicationException("Tried to insert an existing mob id!");
|
||||
throw new OpenDiablo2Exception("Tried to insert an existing mob id!");
|
||||
IdsUsed.Add(mob.Id);
|
||||
}
|
||||
public void RemoveMob(MobState mob)
|
||||
@ -49,7 +50,7 @@ namespace OpenDiablo2.Core.GameState_
|
||||
if (!IdsUsed.Contains(i))
|
||||
return i;
|
||||
|
||||
throw new ApplicationException("Ran out of IDs. How did this even happen?!");
|
||||
throw new OpenDiablo2Exception("Ran out of IDs. How did this even happen?!");
|
||||
}
|
||||
#endregion Mob Controls
|
||||
|
||||
|
@ -19,6 +19,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Interfaces.Drawing;
|
||||
using OpenDiablo2.Common.Models;
|
||||
@ -134,7 +135,7 @@ namespace OpenDiablo2.SDL2_
|
||||
|
||||
animationData = resourceManager.GetPlayerAnimation(Hero, WeaponClass, MobMode);
|
||||
if (animationData == null)
|
||||
throw new ApplicationException("Could not locate animation for the character!");
|
||||
throw new OpenDiablo2Exception("Could not locate animation for the character!");
|
||||
|
||||
var palette = paletteProvider.PaletteTable["Units"];
|
||||
CacheFrames(animationData.Layers.Select(layer => resourceManager.GetPlayerDCC(layer, ArmorType, palette)));
|
||||
@ -221,7 +222,7 @@ namespace OpenDiablo2.SDL2_
|
||||
var offsetX = x + cell.XOffset + (frame.Box.X - minX);
|
||||
var offsetY = y + cell.YOffset + (frame.Box.Y - minY);
|
||||
if (offsetX < 0 || offsetX > frameW || offsetY < 0 || offsetY > frameH)
|
||||
throw new ApplicationException("There is nothing we can do now.");
|
||||
throw new OpenDiablo2Exception("There is nothing we can do now.");
|
||||
|
||||
data[offsetX + (offsetY * (pitch / 4))] = color;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using SDL2;
|
||||
|
||||
@ -85,7 +86,7 @@ namespace OpenDiablo2.SDL2_
|
||||
}
|
||||
|
||||
if (MaxWidth < (font.sprite.FrameSize.Width))
|
||||
throw new ApplicationException("Max label width cannot be smaller than a single character.");
|
||||
throw new OpenDiablo2Exception("Max label width cannot be smaller than a single character.");
|
||||
|
||||
var lastWordIndex = 0;
|
||||
var width = 0;
|
||||
@ -130,7 +131,7 @@ namespace OpenDiablo2.SDL2_
|
||||
|
||||
texture = SDL.SDL_CreateTexture(renderer, SDL.SDL_PIXELFORMAT_ARGB8888, (int)SDL.SDL_TextureAccess.SDL_TEXTUREACCESS_TARGET, textureSize.Width, textureSize.Height);
|
||||
if (texture == IntPtr.Zero)
|
||||
throw new ApplicationException("Unaple to initialize texture.");
|
||||
throw new OpenDiablo2Exception("Unaple to initialize texture.");
|
||||
|
||||
SDL.SDL_SetTextureBlendMode(texture, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
||||
SDL.SDL_SetRenderTarget(renderer, texture);
|
||||
|
@ -18,6 +18,7 @@ using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Interfaces.Drawing;
|
||||
using OpenDiablo2.Common.Models;
|
||||
@ -82,16 +83,16 @@ namespace OpenDiablo2.SDL2_
|
||||
|
||||
SDL.SDL_Init(SDL.SDL_INIT_EVERYTHING);
|
||||
if (SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_SCALE_QUALITY, "0") == SDL.SDL_bool.SDL_FALSE)
|
||||
throw new ApplicationException($"Unable to Init hinting: {SDL.SDL_GetError()}");
|
||||
throw new OpenDiablo2Exception($"Unable to Init hinting: {SDL.SDL_GetError()}");
|
||||
|
||||
window = SDL.SDL_CreateWindow("OpenDiablo2", SDL.SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, 800, 600,
|
||||
SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN | (fullscreen ? SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN : 0));
|
||||
if (window == IntPtr.Zero)
|
||||
throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}");
|
||||
throw new OpenDiablo2Exception($"Unable to create SDL Window: {SDL.SDL_GetError()}");
|
||||
|
||||
renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED | SDL.SDL_RendererFlags.SDL_RENDERER_PRESENTVSYNC);
|
||||
if (renderer == IntPtr.Zero)
|
||||
throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}");
|
||||
throw new OpenDiablo2Exception($"Unable to create SDL Window: {SDL.SDL_GetError()}");
|
||||
|
||||
|
||||
SDL.SDL_SetRenderDrawBlendMode(renderer, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
||||
@ -366,7 +367,7 @@ namespace OpenDiablo2.SDL2_
|
||||
SDL.SDL_SetTextureBlendMode(texId, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
||||
|
||||
if (SDL.SDL_LockTexture(texId, IntPtr.Zero, out IntPtr pixels, out int pitch) != 0)
|
||||
throw new ApplicationException("Could not lock texture for map rendering");
|
||||
throw new OpenDiablo2Exception("Could not lock texture for map rendering");
|
||||
|
||||
try
|
||||
{
|
||||
@ -470,7 +471,7 @@ namespace OpenDiablo2.SDL2_
|
||||
|
||||
var cursor = SDL.SDL_CreateColorCursor(surface, hotspot.X * multiple, hotspot.Y * multiple);
|
||||
if (cursor == IntPtr.Zero)
|
||||
throw new ApplicationException($"Unable to set the cursor cursor: {SDL.SDL_GetError()}"); // TODO: Is this supported everywhere? May need to still support software cursors.
|
||||
throw new OpenDiablo2Exception($"Unable to set the cursor cursor: {SDL.SDL_GetError()}"); // TODO: Is this supported everywhere? May need to still support software cursors.
|
||||
return new SDL2MouseCursor { HWSurface = cursor };
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using SDL2;
|
||||
@ -113,7 +114,7 @@ namespace OpenDiablo2.SDL2_
|
||||
texture = SDL.SDL_CreateTexture(renderer, SDL.SDL_PIXELFORMAT_ARGB8888, (int)SDL.SDL_TextureAccess.SDL_TEXTUREACCESS_STREAMING, Pow2(FrameSize.Width), Pow2(FrameSize.Height));
|
||||
|
||||
if (texture == IntPtr.Zero)
|
||||
throw new ApplicationException("Unaple to initialize texture.");
|
||||
throw new OpenDiablo2Exception("Unaple to initialize texture.");
|
||||
|
||||
Frame = 0;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using OpenDiablo2.Common.Attributes;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
|
||||
namespace OpenDiablo2.ServiceBus.Message_Frames.Client
|
||||
@ -30,7 +31,7 @@ namespace OpenDiablo2.ServiceBus.Message_Frames.Client
|
||||
PlayerName = Encoding.UTF8.GetString(value, 3, value.Length - 3);
|
||||
|
||||
if (PlayerName.Length != playerNameLen)
|
||||
throw new ApplicationException("Invalid player length!");
|
||||
throw new OpenDiablo2Exception("Invalid player length!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ using NetMQ;
|
||||
using NetMQ.Sockets;
|
||||
using OpenDiablo2.Common.Attributes;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.ServiceBus.Message_Frames.Client;
|
||||
using OpenDiablo2.ServiceBus.Message_Frames.Server;
|
||||
@ -89,7 +90,7 @@ namespace OpenDiablo2.ServiceBus
|
||||
case eSessionType.Server:
|
||||
case eSessionType.Remote:
|
||||
default:
|
||||
throw new ApplicationException("This session type is currently unsupported.");
|
||||
throw new OpenDiablo2Exception("This session type is currently unsupported.");
|
||||
}
|
||||
|
||||
running = true;
|
||||
@ -125,7 +126,7 @@ namespace OpenDiablo2.ServiceBus
|
||||
private void ProcessMessageFrame<T>() where T : IMessageFrame, new()
|
||||
{
|
||||
if (!running)
|
||||
throw new ApplicationException("You have made a terrible mistake. Cannot get a message frame if you are not connected.");
|
||||
throw new OpenDiablo2Exception("You have made a terrible mistake. Cannot get a message frame if you are not connected.");
|
||||
|
||||
var bytes = requestSocket.ReceiveFrameBytes();
|
||||
var frameType = (eMessageFrameType)bytes[0];
|
||||
@ -133,7 +134,7 @@ namespace OpenDiablo2.ServiceBus
|
||||
var frameData = bytes.Skip(1).ToArray(); // TODO: Can we maybe use pointers? This seems wasteful
|
||||
var messageFrame = getMessageFrame(frameType);
|
||||
if (messageFrame.GetType() != typeof(T))
|
||||
throw new ApplicationException("Recieved unexpected message frame!");
|
||||
throw new OpenDiablo2Exception("Recieved unexpected message frame!");
|
||||
messageFrame.Data = frameData;
|
||||
lock (getGameState().ThreadLocker)
|
||||
{
|
||||
@ -145,7 +146,7 @@ namespace OpenDiablo2.ServiceBus
|
||||
{
|
||||
var bytes = requestSocket.ReceiveFrameBytes();
|
||||
if ((eMessageFrameType)bytes[0] != eMessageFrameType.None)
|
||||
throw new ApplicationException("Excepted a NoOp but got a command instead!");
|
||||
throw new OpenDiablo2Exception("Excepted a NoOp but got a command instead!");
|
||||
}
|
||||
|
||||
public void JoinGame(string playerName, eHero heroType)
|
||||
|
@ -22,6 +22,7 @@ using NetMQ;
|
||||
using NetMQ.Sockets;
|
||||
using OpenDiablo2.Common.Attributes;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.ServiceBus.Message_Frames.Server;
|
||||
@ -84,7 +85,7 @@ namespace OpenDiablo2.ServiceBus
|
||||
case eSessionType.Server:
|
||||
case eSessionType.Remote:
|
||||
default:
|
||||
throw new ApplicationException("This session type is currently unsupported.");
|
||||
throw new OpenDiablo2Exception("This session type is currently unsupported.");
|
||||
}
|
||||
|
||||
OnJoinGame += OnJoinGameHandler;
|
||||
|
@ -1,16 +1,13 @@
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.Core;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.Core;
|
||||
|
||||
namespace OpenDiablo2.TestConsole
|
||||
{
|
||||
class Program
|
||||
static class Program
|
||||
{
|
||||
private static GlobalConfiguration GlobalConfig = null;
|
||||
private static MPQProvider MPQProv = null;
|
||||
|
Loading…
Reference in New Issue
Block a user