[QUOTE=Ziks;49871489]And if that didn't make you go insane, try this: [url]https://raw.githubusercontent.com/TheVamp/Terraria-Source-Code/master/Terraria/NPC.cs[/url][/QUOTE]
I thought I was terrible because I had two if-else statements inside of just one. I look at this and it looks like a mountain range.
[t]http://i.imgur.com/V5x4lfq.png[/t]
I hope this is the decompilers fault because now I don't have to take a plane trip to the Himalayas to get a good view.
Edit:
i just noticed how far back the post is, whatever the joke was worth it :v:
Edit 2:
Some actual content, I am tired and uninspired to do any engine work today, instead I decided to revisit a old project: Previewer!
Since Windows 10 has deprecated the original win32 photo viewer for the new metro clone (imho it's crappy) I thought it was a nice project to start. It has GIF support and has all the zooming you can imagine. After I have been using it for a few months I got tired of the same old bugs that plagued it and thought it could do with a little refactoring:
[code]
New Features:
- Changed error messages to be more descriptive and clear.
- Instead of one message, there are now multiple messages pertaining to the error, examples:
- "No image open" when no image is actually open.
- "Image can't be read" when the image can't be read.
- Now the antialiasing settings now are persistent between sessions.
- Major code refactoring, removed redunandices in file path handling and code is much more readable.
- Images are now a class itself, removes a lot of code checking multiple variables related to the image.
- More error-checking should make the program less error-prone.
- Disabling and enabling menus are now handled in a update function.
- Window should now be brought to the front, stops it from getting stuck behind windows when opening images.
- The program won't search through the same directory twice
Bugfixes:
- Fixed bug where file extensions in uppercase (or anything in between) is considered not supported.
- Fixed a bug where going through files very fast will cause a crash.
- Some extensions (cough webm cough) get past the initial file extension check, so now the program will now ignore opening files that are not supported a second time.
- Using the close button now exists out of the current directory (can't go back and forth between images).
- Now can't open the properties button of no image and crash
[/code]
Next time I need throw out the ugly UI for something better, and maybe webm support because i'm tired of only being able to view webm in browsers. You can download it [URL="https://dl.dropboxusercontent.com/u/357850863/ShareX/2016/03/Previewer.exe"]here[/URL]. The source can be downloaded [URL="https://dl.dropboxusercontent.com/u/357850863/ShareX/2016/03/Previewer-source-2.0.zip"]here [/URL](it's less ugly than before, I promise)
[QUOTE=Ziks;49871489]And if that didn't make you go insane, try this: [url]https://raw.githubusercontent.com/TheVamp/Terraria-Source-Code/master/Terraria/NPC.cs[/url][/QUOTE]
If you scroll fast enough, it kinda looks like "Through the Fire and Flames" on expert in Guitar Hero :v:
[IMG]http://i.imgur.com/hL3vRPc.png[/IMG]
Who wants to try my game? I just released the alpha and I need some testers.
Get a free key here (50 available): [URL]http://crashlightarena.com/facepunchkeys.html[/URL]
Go to the URL and redeem the key on itch.io.
You should get a download link and a key for the game.
Launch the game and register an email/password for that key.
Website for the game: [URL="http://www.crashlightarena.com"]www.crashlightarena.com[/URL]
Also someone on facepunch came up with the name "crashlight", so thanks to whoever that was!
My game is slowly coming together, and I am currently trying to write a 2d physics engine for it.
I don't want to use existing solutions due to very specific features the physics engine ought to have.
That's the first time I'm doing something like that in C++ and boy, this is a world of pain and a half.
So far I've done the obvious stuff, i.e.
- Locked the timestep(physics and drawing are ran in separate threads with their respective rather strict fps limits).
- Rudimentary physics integration(aka pos = pos + vel*dt) to test drawing/motion.
- Implemented vector/angle math lib to work with.
- Decided to approximate physics via polygons; Decided using SAT to detect polygon-polygon collision. Still need some way to deal with concave polygons, though...
And now I'm completely stumped; Cannot figure out what architecture of physics objects/engine would be best, how to trigger collision events only one time, et cetera.
Had anyone here had any experience with building their own physics engine?
I'd be much obliged for any recommendations on proper way to set up this whole system in C++. Vector math, I can take, but OOP has been my mortal enemy every time I tried to plan architecture ahead.
In today's episode of why am I never productive we run duplicate image detection over the Firefox cache.
[t]http://i.imgur.com/GE69EmO.png[/t]
Why are there 40 of these.
[t]http://i.imgur.com/k6HJrHJ.png[/t]
Why are there 9 of these.
getting into half-life modding
[vid]http://webm.land/media/iHpr.webm[/vid]
[QUOTE=sarge997;49872637]Guys, don't you know what this means! We've found the path to extraordinary wealth!
All we need to do is follow Terraria's development path, and use IF statements for everything![I] It's so simple! [/I][I][B]We're gonna be rich![/B][/I]
[B]IF statements.. IF statements everywhere![/B] :magic101:[/QUOTE]
Must be nullsquared's sibling.
[QUOTE=Cold;49872869]I wish both of you would leave and never come back.[/QUOTE]
Geel is right though
[QUOTE=sarge997;49872637]Guys, don't you know what this means! We've found the path to extraordinary wealth!
All we need to do is follow Terraria's development path, and use IF statements for everything![I] It's so simple! [/I][I][B]We're gonna be rich![/B][/I]
[B]IF statements.. IF statements everywhere![/B] :magic101:[/QUOTE]
Compiling and Decompiling a C# code will turn switch statements into if-elses. Of course they didn't code it like that.
- edit -
I'm wrong and switch does compile to its own switch instruction in CIL. But in some cases it does compile to if-elses.
[QUOTE=MatheusMCardoso;49878156]Compiling and Decompiling a C# code will turn switch statements into if-elses. Of course they didn't code it like that.[/QUOTE]
[code]if (this.prefix == 1)
{
text = "Large";
}
if (this.prefix == 2)
{
text = "Massive";
}
if (this.prefix == 3)
{
text = "Dangerous";
}[/code]
I see no elses. I don't think the compiler would strip those, though maybe the IL it compiles to confuses the decompiler enough that it doesn't think there are elses there.
[QUOTE=TheEyes;49875183]What are You Working On - Everybody argues with adnzzzzZ [I]AGAIN[/I] edition[/QUOTE]
I don't understand the obsession you people have against arguments. Arguments are the way people share ideas and learn from each other. People who don't argue with others will never grow and learn, or will do so at a much slower pace.
[video=youtube;ABB1pfi3ZpE]http://www.youtube.com/watch?v=ABB1pfi3ZpE[/video]
[QUOTE=adnzzzzZ;49878314]I don't understand the obsession you people have against arguments. Arguments are the way people share ideas and learn from each other. People who don't argue with others will never grow and learn, or will do so at a much slower pace.[/QUOTE]
This is something I actually agree with you on.
Well then maybe you two can go argue over PM's.
Instead of cloggin up the thread.
[QUOTE=MatheusMCardoso;49878156]Compiling and Decompiling a C# code will turn switch statements into if-elses. Of course they didn't code it like that.[/QUOTE]
Here's some code: [code]using System;
namespace Sketchpad
{
static class Branching
{
static string Switching(int i)
{
string result;
switch (i)
{
case 0: result = "a"; break;
case 1: result = "b"; break;
case 2: result = "c"; break;
case 3: result = "d"; break;
case 4: result = "e"; break;
case 5: result = "f"; break;
case 6: result = "g"; break;
case 7: result = "h"; break;
case 8: result = "i"; break;
case 9: result = "j"; break;
default: throw new ArgumentOutOfRangeException(nameof(i));
}
return result;
}
}
}[/code]
Here's what that compiles to: [code].class private auto ansi abstract sealed beforefieldinit Sketchpad.Branching
extends [mscorlib]System.Object
{
// Methods
.method private hidebysig static
string Switching (
int32 i
) cil managed
{
// Method begins at RVA 0x2660
// Code size 141 (0x8d)
.maxstack 1
.locals init (
[0] string
)
IL_0000: ldarg.0
IL_0001: switch (IL_0030, IL_0038, IL_0040, IL_0048, IL_0050, IL_0058, IL_0060, IL_0068, IL_0070, IL_0078)
IL_002e: br.s IL_0080
IL_0030: ldstr "a"
IL_0035: stloc.0
IL_0036: br.s IL_008b
IL_0038: ldstr "b"
IL_003d: stloc.0
IL_003e: br.s IL_008b
IL_0040: ldstr "c"
IL_0045: stloc.0
IL_0046: br.s IL_008b
IL_0048: ldstr "d"
IL_004d: stloc.0
IL_004e: br.s IL_008b
IL_0050: ldstr "e"
IL_0055: stloc.0
IL_0056: br.s IL_008b
IL_0058: ldstr "f"
IL_005d: stloc.0
IL_005e: br.s IL_008b
IL_0060: ldstr "g"
IL_0065: stloc.0
IL_0066: br.s IL_008b
IL_0068: ldstr "h"
IL_006d: stloc.0
IL_006e: br.s IL_008b
IL_0070: ldstr "i"
IL_0075: stloc.0
IL_0076: br.s IL_008b
IL_0078: ldstr "j"
IL_007d: stloc.0
IL_007e: br.s IL_008b
IL_0080: ldstr "i"
IL_0085: newobj instance void [mscorlib]System.ArgumentOutOfRangeException::.ctor(string)
IL_008a: throw
IL_008b: ldloc.0
IL_008c: ret
} // end of method Branching::Switching
} // end of class Sketchpad.Branching[/code]
Note the [URL="https://msdn.microsoft.com/library/system.reflection.emit.opcodes.switch.aspx"]switch instruction[/URL] in the IL code.
Here's what that decompiles to as C# code: [code]using System;
namespace Sketchpad
{
internal static class Branching
{
private static string Switching(int i)
{
string result;
switch (i)
{
case 0:
result = "a";
break;
case 1:
result = "b";
break;
case 2:
result = "c";
break;
case 3:
result = "d";
break;
case 4:
result = "e";
break;
case 5:
result = "f";
break;
case 6:
result = "g";
break;
case 7:
result = "h";
break;
case 8:
result = "i";
break;
case 9:
result = "j";
break;
default:
throw new ArgumentOutOfRangeException("i");
}
return result;
}
}
}[/code]
It would be more work to turn that into an [I]if[/I]/[I]else[/I] than to keep the [I]switch[/I] statement.
Even with only partially consecutive identifiers and switched cases like [code]using System;
namespace Sketchpad
{
static class Branching
{
static string Switching(int i)
{
string result;
switch (i)
{
case 0: result = "a"; break;
case 1: result = "b"; break;
case 2: result = "c"; break;
case 3: result = "d"; break;
case 4: result = "e"; break;
case 21: result = "g"; break;
case 20: result = "f"; break;
case 22: result = "h"; break;
case 23: result = "i"; break;
case 90: result = "j"; break;
default: throw new ArgumentOutOfRangeException(nameof(i));
}
return result;
}
}
}[/code] the compiler turns that into [code].class private auto ansi abstract sealed beforefieldinit Sketchpad.Branching
extends [mscorlib]System.Object
{
// Methods
.method private hidebysig static
string Switching (
int32 i
) cil managed
{
// Method begins at RVA 0x2660
// Code size 151 (0x97)
.maxstack 2
.locals init (
[0] string
)
IL_0000: ldarg.0
IL_0001: switch (IL_003a, IL_0042, IL_004a, IL_0052, IL_005a)
IL_001a: ldarg.0
IL_001b: ldc.i4.s 20
IL_001d: sub
IL_001e: switch (IL_006a, IL_0062, IL_0072, IL_007a)
IL_0033: ldarg.0
IL_0034: ldc.i4.s 90
IL_0036: beq.s IL_0082
IL_0038: br.s IL_008a
IL_003a: ldstr "a"
IL_003f: stloc.0
IL_0040: br.s IL_0095
IL_0042: ldstr "b"
IL_0047: stloc.0
IL_0048: br.s IL_0095
IL_004a: ldstr "c"
IL_004f: stloc.0
IL_0050: br.s IL_0095
IL_0052: ldstr "d"
IL_0057: stloc.0
IL_0058: br.s IL_0095
IL_005a: ldstr "e"
IL_005f: stloc.0
IL_0060: br.s IL_0095
IL_0062: ldstr "g"
IL_0067: stloc.0
IL_0068: br.s IL_0095
IL_006a: ldstr "f"
IL_006f: stloc.0
IL_0070: br.s IL_0095
IL_0072: ldstr "h"
IL_0077: stloc.0
IL_0078: br.s IL_0095
IL_007a: ldstr "i"
IL_007f: stloc.0
IL_0080: br.s IL_0095
IL_0082: ldstr "j"
IL_0087: stloc.0
IL_0088: br.s IL_0095
IL_008a: ldstr "i"
IL_008f: newobj instance void [mscorlib]System.ArgumentOutOfRangeException::.ctor(string)
IL_0094: throw
IL_0095: ldloc.0
IL_0096: ret
} // end of method Branching::Switching
} // end of class Sketchpad.Branching[/code] which is equivalent of the following C# code: [code]using System;
namespace Sketchpad
{
internal static class Branching
{
private static string Switching(int i)
{
string result;
switch (i)
{
case 0:
result = "a";
break;
case 1:
result = "b";
break;
case 2:
result = "c";
break;
case 3:
result = "d";
break;
case 4:
result = "e";
break;
default:
switch (i)
{
case 20:
result = "f";
break;
case 21:
result = "g";
break;
case 22:
result = "h";
break;
case 23:
result = "i";
break;
default:
if (i != 90)
{
throw new ArgumentOutOfRangeException("i");
}
result = "j";
break;
}
break;
}
return result;
}
}
}[/code]
(Almost?) all [I]if[/I]/[I]else if[/I] branches in Terraria are consecutive, so I'd expect to see mostly switch statements for these, with possibly some other branches if there are larger jumps in the indexing.
On a related note, if I skip a single index ([code]using System;
namespace Sketchpad
{
static class Branching
{
static string Switching(int i)
{
string result;
switch (i)
{
case 0: result = "a"; break;
//case 1: result = "b"; break;
case 2: result = "c"; break;
case 3: result = "d"; break;
case 4: result = "e"; break;
case 21: result = "g"; break;
case 20: result = "f"; break;
case 22: result = "h"; break;
case 23: result = "i"; break;
case 90: result = "j"; break;
default: throw new ArgumentOutOfRangeException(nameof(i));
}
return result;
}
}
}[/code]) that turns the method into [code].class private auto ansi abstract sealed beforefieldinit Sketchpad.Branching
extends [mscorlib]System.Object
{
// Methods
.method private hidebysig static
string Switching (
int32 i
) cil managed
{
// Method begins at RVA 0x2660
// Code size 143 (0x8f)
.maxstack 2
.locals init (
[0] string
)
IL_0000: ldarg.0
IL_0001: switch (IL_003a, IL_0082, IL_0042, IL_004a, IL_0052)
IL_001a: ldarg.0
IL_001b: ldc.i4.s 20
IL_001d: sub
IL_001e: switch (IL_0062, IL_005a, IL_006a, IL_0072)
IL_0033: ldarg.0
IL_0034: ldc.i4.s 90
IL_0036: beq.s IL_007a
IL_0038: br.s IL_0082
IL_003a: ldstr "a"
IL_003f: stloc.0
IL_0040: br.s IL_008d
IL_0042: ldstr "c"
IL_0047: stloc.0
IL_0048: br.s IL_008d
IL_004a: ldstr "d"
IL_004f: stloc.0
IL_0050: br.s IL_008d
IL_0052: ldstr "e"
IL_0057: stloc.0
IL_0058: br.s IL_008d
IL_005a: ldstr "g"
IL_005f: stloc.0
IL_0060: br.s IL_008d
IL_0062: ldstr "f"
IL_0067: stloc.0
IL_0068: br.s IL_008d
IL_006a: ldstr "h"
IL_006f: stloc.0
IL_0070: br.s IL_008d
IL_0072: ldstr "i"
IL_0077: stloc.0
IL_0078: br.s IL_008d
IL_007a: ldstr "j"
IL_007f: stloc.0
IL_0080: br.s IL_008d
IL_0082: ldstr "i"
IL_0087: newobj instance void [mscorlib]System.ArgumentOutOfRangeException::.ctor(string)
IL_008c: throw
IL_008d: ldloc.0
IL_008e: ret
} // end of method Branching::Switching
} // end of class Sketchpad.Branching[/code], which is [code]using System;
namespace Sketchpad
{
internal static class Branching
{
private static string Switching(int i)
{
switch (i)
{
case 0:
{
string result = "a";
return result;
}
case 1:
break;
case 2:
{
string result = "c";
return result;
}
case 3:
{
string result = "d";
return result;
}
case 4:
{
string result = "e";
return result;
}
default:
switch (i)
{
case 20:
{
string result = "f";
return result;
}
case 21:
{
string result = "g";
return result;
}
case 22:
{
string result = "h";
return result;
}
case 23:
{
string result = "i";
return result;
}
default:
if (i == 90)
{
string result = "j";
return result;
}
break;
}
break;
}
throw new ArgumentOutOfRangeException("i");
}
}
}[/code] when decompiled to C# in ILSpy. Pretty ugly but it's still switching.
-snip-
[QUOTE=adnzzzzZ;49878314]I don't understand the obsession you people have against arguments. Arguments are the way people share ideas and learn from each other. People who don't argue with others will never grow and learn, or will do so at a much slower pace.
[video=youtube;ABB1pfi3ZpE]http://www.youtube.com/watch?v=ABB1pfi3ZpE[/video][/QUOTE]
you aren't even arguing properly though
you're just flinging shit at each other
-snip-
[QUOTE=Tamschi;49878412]
decompiled code and stuff
[/QUOTE]
Wow this means one thing... Terraria code is the worst code I have ever seen in my life, actually it's sum of all bad codes together
Update: Bugs you guys found fixed.
-Two new rooms, grass rooms and dark rooms.
-Weapon lockers.
-New enemy.
-Ammo system added.
-Shop fixed.
-Poison added.
-Diagonal movement.
-Bunch of new graphics
-Loads more stuff I'm forgetting
[url]https://dl.dropboxusercontent.com/u/124783721/index.html[/url]
[QUOTE=adnzzzzZ;49878314]I don't understand the obsession you people have against arguments. Arguments are the way people share ideas and learn from each other. People who don't argue with others will never grow and learn, or will do so at a much slower pace.
[video=youtube;ABB1pfi3ZpE]http://www.youtube.com/watch?v=ABB1pfi3ZpE[/video][/QUOTE]
yeah because starting arguments on a forum is always constructive right
[QUOTE=Fourier;49878708]Wow this means one thing... Terraria code is the worst code I have ever seen in my life, actually it's sum of all bad codes together[/QUOTE]
As long as it still reliably works it's not [I]that[/I] terrible :v:
Some of you might like this:
[url]https://github.com/Sidneys1/TheCloset/tree/master/TheCloset/ConsoleHelpers[/url]
Feel free to use in whatever! Some of it is still a little rough
[editline]6th March 2016[/editline]
Also, while I'm here, I set up a personal GitLab. You can view public-visibility projects here: [url]http://gitlab.sidneys1.io/explore/projects[/url]
[QUOTE=chaz13;49878756]Update: Bugs you guys found fixed.
-Two new rooms, grass rooms and dark rooms.
-Weapon lockers.
-New enemy.
-Ammo system added.
-Shop fixed.
-Poison added.
-Diagonal movement.
-Bunch of new graphics
-Loads more stuff I'm forgetting
[url]https://dl.dropboxusercontent.com/u/124783721/index.html[/url][/QUOTE]
Chrome froze up when I went down 2 floors
[t]http://i.imgur.com/nSgqsxj.png[/t]
[QUOTE=chaz13;49878756]Update: Bugs you guys found fixed.
-Two new rooms, grass rooms and dark rooms.
-Weapon lockers.
-New enemy.
-Ammo system added.
-Shop fixed.
-Poison added.
-Diagonal movement.
-Bunch of new graphics
-Loads more stuff I'm forgetting
[url]https://dl.dropboxusercontent.com/u/124783721/index.html[/url][/QUOTE]
Nice, this looks quite cool for something like android tablets. Remind me of Pixel Dungeon.
[QUOTE=Fourier;49879961]Nice, this looks quite cool for something like android tablets. Remind me of Pixel Dungeon.[/QUOTE]
That was the original plan before I stopped working on it, then it occurred to me it'd work nicely as a browser game too :smile:
[QUOTE=Ott;49879849]Chrome froze up when I went down 2 floors
[t]http://i.imgur.com/nSgqsxj.png[/t][/QUOTE]
Uh oh. Catching errors in HTML5 is nightmarish, I was really hoping I'd found the last game-breaking bugs hah.
[url]https://facepunch.com/showthread.php?t=1509392[/url]
Made a post in GGD for my game. Theres still 45 unclaimed keys
Having the signature was still bugging me. So suddenly, QR codes struck. It's the future, no more signatures, QR codes :P
[img]http://i.imgur.com/PkCvFxb.png[/img]
QR codes were cool in 2007 before everyone realized that they were less convenient than just reading a shortlink.
[QUOTE=chimitos;49880678]QR codes were cool in 2007 before everyone realized that they were less convenient than just reading a shortlink.[/QUOTE]
True, they aren't really practical. But they look a bit futuristic, so that's what counts. The data IS valid, but eh. I think it looks a bit better then a actual pen signature if you think that it's set in the year 2078 or so.
[QUOTE=Arxae;49880713]True, they aren't really practical. But they look a bit futuristic, so that's what counts. The data IS valid, but eh. I think it looks a bit better then a actual pen signature if you think that it's set in the year 2078 or so.[/QUOTE]
It may be better for me not to question the validity of a QR code being in a terminal game set in 2078 :v:
Sorry, you need to Log In to post a reply to this thread.