Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Josh @ Dreamland

Announcements / Re: Encryption
« on: March 05, 2010, 11:08:46 pm »
That's a tad more specific than what I was describing. It'd also require a lot of template instantiations.

Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 09:54:21 pm »
The only difference between const char* and char* is that const char* points to read-only memory. And even that's only on systems that support such (ie, not Windows). '\0' == 0, and I'd be willing to bet that if you were to compare {'n','o',0} and "no" you'd get that they were equivalent. And I do mean as-is.

"Test" == "test" compares correctly for string literals. "Test" == "test" will return false, "test" == "test" will return true. This is because they point to the same location in memory when GCC is done with them.

Also, you don't need to use const_cast to get it represented as a const char. :P
Const char* can be set to a char* without cast. Vice-versa requires cast, but is dangerous on Linux and the like.

Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 09:33:35 pm »
He's thinking about 'situations where you need to quote "' + "that's" + '," or other situations requiring both "' + " and '".

Announcements / Re: Pride
« on: March 05, 2010, 07:24:18 pm »
I use a goto roughly four times in the C parser. My labels are usually descriptive and located nearby. Usually.

Announcements / Re: Encryption
« on: March 05, 2010, 03:26:50 pm »
The only way that could have anything to do with typing is if I made a class that did the checks on operator=, which wasn't what I was suggesting.

Announcements / Re: Pride
« on: March 05, 2010, 10:34:32 am »
It's by no means a hack. GML does support switch(); it will let you switch either a real or string. Switching an array switches its first value.
Just because a code uses goto doesn't mean it's a hack. Goto was excommunicated from use in high level code due to it making said code difficult to read when misused. Case labels are just that: labels. The compiler writes the hash map instead of me doing it. The same will apply to ENIGMA.

Announcements / Re: Encryption
« on: March 04, 2010, 07:20:40 pm »
I could have worded that better. - fix'd

I meant that it could do such things as find locations where given variables are modified. The conditions of the set could then be relayed to the server-side module. That could of course be spoofed, but it'd be a step.

I think a more comprehensive idea would be to have submit the locations of certain key objects along with any changes; the server would allow a small tolerance accounted for by lag. No one likes missing a shot because the server and client disagree on a location.

So, a function could be defined for call when a certain variable is set or action is performed requesting a double check on locations and allowing the server to double check the math.

Frankly, I'm not sure how convenient such an idea would be, hence my not promoting it or "making any promises."

Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 06:44:39 pm »
String already defines those...
And then some...

Announcements / Re: Pride
« on: March 04, 2010, 06:23:53 pm »
Retro and other concerned individuals:

In the case that strings are involved, it'd be a hijacked switch. What I was hinting at is basically this (assume that the hash of "hello" and "herro" is 143):

Code: [Select]
case 143:
  if (enigma::sval == "hello") { ... }
  if (enigma::sval == "herro") { ... }

Note, however, a couple things:
1) Ideally, the hash function would be played with a little bit to try to achieve the fewest collisions possible
2) An actual hijacked switched statement would look more like this:
Code: [Select]
switch hash()
    case hash: if (...) goto ...
    case hash: if (...) goto ...
3) The most ideal option, but perhaps a more difficult one, is to do the hash map myself, storing pointers to goto labels in my own array (this is legal in C)
This would look like this:
goto enigma::hashmap_switch_1[sval];
Where operator[] computes the hash, starts raiding pre-defined buckets for the correct label, then returns it for jump. This is how switch() actually works, and how I hope to do it.

Announcements / Re: Encryption
« on: March 04, 2010, 06:07:50 pm »
Hmmmm... ENIGMA would be great for server side code if the graphics system could be disabled as easily as I intend...
Code to implement the framework for a set of simple checks could be integrated into the parser or something, but I'm not making any promises until I have a plan for such. Doesn't help that I hate coding online things.

Announcements / Re: Pride
« on: March 03, 2010, 06:20:22 pm »

Oh, and Fede: Many people use primitives for circle-related effects. Think ripples or rings. Especially awesome with surfaces.

Announcements / Re: Pride
« on: March 03, 2010, 01:49:58 pm »
I do love my parentheses (and messing with you). Really, they're mostly for thoughts that might confuse the rest of the sentence; I separated them because they are confusing or because they are pieces of info that those who read them should probably know.


Since if I even hint it's toward the end of the month, you'll guess what day it is, I may as well tell you I want it out on April Fool's day. I might release some things for testing around the 15th or 20th.

Announcements / Re: Pride
« on: March 02, 2010, 11:36:56 pm »
Yeah, using namespace std works. I asked it to print the using scope... it took five seconds or so...
Asking it to print everything it had just parsed took 36 seconds. Heh...

Announcements / Pride
« on: March 02, 2010, 11:21:36 pm »
I'm so proud of this little community for not hanging on security considerations when looking to the efficiency ones. :3

Good news. Here's the result of parsing this code:

Code: [Select]
#include <map>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <iostream>

#include <windows.h>

No error.
Parse time: 1509 milliseconds

Macros (12684) [+ ]
Variables [+ ]
Define: CreateWindow
  #define CreateWindow CreateWindowA
Define: CreateWindowA
  #define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k) CreateWindowExA(0,a,b,c,d,e,f,g,h,i,j,k)
Define: CreateWindowExA
  CreateWindowExA:  Function with 12 parameters, returning HWND__  Dereference path: (params = 786444)*</group>

Since Windows includes everything, and I do mean everything, that anyone could ever need to make a game, there's really no point in assuming the parser needs further work. The parser no longer requires lists of functions and types.

Oh, and, if you noticed the odd parameter count when I asked it to define CWExA, don't worry, it stores that count in a jumbled short. It used to dissect the short and display the actual parameter bounds, but the code that does so got lost in one SVN commit or another.

Since you've all proven to be concerned with efficiency, here are some related tidbits of considerations:

1) The most pressing efficiency loss when treating EDL more like GML than C relates to the switch () statement. Those of you who are particularly well-informed with either GM or ENIGMA know that both engines treat a switch like a less-ugly chain of if()s. The complexity is the same; an == check for each label. A consideration, however, is to make a small, close-to-perfect hash function. Basically, this will allow for var case labels using some template magic. GM People: Stop reading after this next sentence.

I believe this can be done in O(1), maybe with two or three checks a number. Basically, a hash function will be used on the input to each case label, assuming these are constant. (Thanks to the C parser, checking can be done on this when they are not literals [such as 3.14 or "some string"]. How great is that?) Basically, the hash will take the sum of first and last byte of any strings along with its length, do some round() tricks on floats, and leave ints alone (C++ doesn't allow switching anything but int, and doesn't allow case labels of anything but constant int). Now, the thought of course is, what if two strings produce the same hash? That's why one check is done at the case label. You'll see the same idea being employed in hash maps. I owe it to Luda that I was enlightened to it. If anyone has a better idea, of course, by all means...

2) The next most annoying thing is compatibility garbage related to simple functions, like draw_primitive_begin(). From my reckonings, GM uses DirectX's idea of a Vertex Buffer Object. That's not always an option for GL... R3 and lower use glBegin(). This raises a compatibility issue when drawing two at once (this is allowed in GML, but not in GL). The reason I assume GM uses VBO is that it can in fact keep two separate primitives going at once. Long, long ago I decided to deal with the problem by allowing a statically allocated array to be used to hold the points for quick iteration... I made it static because I didn't want the overhead each function call to make sure we hadn't overflown anything and needed more space. However, this meant either an annoying amount of memory overhead, or an equally or more annoying setting to allow the maximum number of points to be set. (I thought 360 would be reasonable for most applications, but...) Anyway, in retrospect, it was an awful idea (good thing it was #if'd out by default). I think the plan should be to try for VBO, but if it doesn't exist, just offer glBegin(), no buffering. (This would break some compatibility for people with Intel cards barely meeting stone-age GL specifications). The good news is, no one who had any decent coding practice would notice the break.

I figured I'd get your opinions on those little things as well. If/when there is a DirectX port, that won't really be a concern (the nice thing is that with DirectX, we can make the same decisions as Yoyo did, good or bad, and no one can complain. Too bad I'm still using GL).

I'd throw in a third thing, but that's probably enough to swallow for one post. Those who would like to put their two cents in on security issues can do so in the previous thread. I guess we'll just keep doing this until I have a public opinion on the decisions that haunted me in early development stages (I want to get it all right this time. Or at least most of it).

While you people decide that, I'll be replacing lists of types and functions in the GML formatter with the new lookup calls. (Also, I think I need to make sure "using namespace" works in the global scope. )

Announcements / Re: Rejoice
« on: March 02, 2010, 10:44:54 pm »
Serp shortcuts. Makes a great optimizer.