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

2446
Announcements / Re: R3 isn't dead
« on: December 11, 2009, 03:52:15 PM »
None of my new syntax adaptations will prevent GML from working. In fact, some of R4's changes bring it closer to working like GM, such as var::operator bool(). Serp and I were just discussing a discrepancy where if (.5) is evaluated as true in GM. I'd known this since the start, of course, but only now do I have a method of doing that (Overloading bool before would have conflicted with std::string).

So, yes, the objective is still to allow backwards compatibility with GM.

2447
Announcements / Re: R3 isn't dead
« on: December 10, 2009, 07:29:20 PM »
*shrug*

That was a bit graphic a depiction. But yes, most of R3 is antiquated. That doesn't mean I'm going back on the idea of full GM support, of course, I just can't have ENIGMA be as pathetic as GM.

2448
Tips, Tutorials, Examples / Re: draw_healthbar() function
« on: December 09, 2009, 06:58:43 AM »
You know, I gave it some thought, and I think that although what you're doing wouldn't be good for small peeks into big files, it's best to do what you're doing now. You use a good deal of C methods in it, such as strcmp rather than std::string's assortment of goodies. Is this to save the eight byte prefix? I'm thinking that string::operator== may be faster than strcmp in most cases, at the cost of the eight bytes.

I'd inline swapints, but I think GCC will do that for you (Inline void instead of void).

Overall though, the code is good. You seem to have a good grasp of the language, regardless of how long you've been using it.

When you are done, you can either take a whack at this or I'll do it later, it doesn't matter: I'm thinking that to improve speed for bigger files (at the cost of a deal of memory) you could use std::map either alongside or instead of your linked list, chain. Using it as an alternative will alphabetize everything, which you may not want. Using it alongside will save on lookup (no iterating every chain).
in the class,
map<string,Section*> sections;
typedef map<string,Section*>::iterator sec_it;

Then FindSection will be
{
  sec_it it = sections.find(sectname);
  if (it != sections.end())
    return it->second;
  return NULL;
}

It'd make your life easier, anyway. If you were specifically avoiding map so it wouldn't alphabetize things, the code's basically perfect. (I can't remember if GM does so or not, sadly). One last thing I'd recommend is adding the license at the top. ;)

Oh, and I'm used to working with no comments. Your code was rather clean and easy to navigate.

2449
Tips, Tutorials, Examples / Re: draw_healthbar() function
« on: December 08, 2009, 10:48:49 PM »
Most of the things you can do by loading it into memory can be done with BUFSIZ buffers loaded one at a time, and fseek(), but I'll trust your judgment, especially if the benchmarks are similar.

2450
Tips, Tutorials, Examples / Re: draw_healthbar() function
« on: December 08, 2009, 09:24:06 PM »
Use show_error as GM defines it. I'm not sure how liberally that function is implemented in R3, but it'll be alive in full force for R4. If nothing else, implement it yourself in your code (int show_error(string e,int fatal) { cout << "error: "<<e<<endl; return fatal; }), and I will make sure it doesn't throw a linker error before R4 is released (Or you can, really. I trust you'll know how).

Also, good to know it's GPL.

2451
Tips, Tutorials, Examples / Re: A Few Alternate Functions
« on: December 08, 2009, 09:21:01 PM »
>_<"

What Rusky said.

2452
Announcements / Re: Changes
« on: December 08, 2009, 09:17:00 PM »
No, they're not. A used element is used. Permanently. I can allow for the array to be manually resized by the user. It'll look something like this:

var a;
a[0] = 1; a[1] = 2; a[2] = 3;
//Method 1:
a.resize(2);
//Method 2:
array_resize(a,1);

2453
Announcements / Re: Changes
« on: December 08, 2009, 04:31:13 PM »
Well.

serp--
It isn't how GM works. a would have two elements in GM, (0,hugearray[0]) and (4,4).

2454
Tips, Tutorials, Examples / Re: draw_healthbar() function
« on: December 08, 2009, 04:29:12 PM »
Supposedly. I don't know the particulars.

2455
Tips, Tutorials, Examples / Re: draw_healthbar() function
« on: December 08, 2009, 05:28:30 AM »
Retro:
I think on account of my own forgetfulness, ENIGMA doesn't have any form of working switch(). It replaces them with some functions that I *believe* were never implemented. But if I did implement those three functions, it'd work. I believe GM switch() statements share complexity with a string of if()s, so that's what ENIGMA does. Ideally, I want to optimize the code, only replacing switch with if()s when I can't tell that all case labels and the input are integers.

Revel:
I'd love that. I made some kind of text file implementation that I never documented (in any form, I mean), but I never did do INI. Is your code GPL?

2456
Announcements / Re: Changes
« on: December 08, 2009, 05:14:58 AM »
Bahahahaha.

Either way, that's seven. I don't have a personal vendetta against it. Yet.

Oh, and Luis. Casts are magic. var::var(var) and var::operator= (const var&) can "copy" the entire array in C++. I place copy in quotes because it'll be copy-on-write. If your sole purpose is to read an array passed as a parameter, it'll be done in constant time. Only if you start editing the array will it copy. That means that var can be passed as an array as well as copied. The cost of such an action is efficiency if no intelligence is used. For example:

a = hugearray;
a += 4;

Will function the same in GM and ENIGMA, as far as users can tell. In actuality, the ENIGMA one will be slower unless users say

a = hugearray[0];
a += 4;

Which any respectable GM user would do.
Copying on write makes only the most blatant (and I do mean stupid) instances of GM syntax slow. Even just implicitly passing the first element in an array as an argument won't be any slower, unless they set the argument somewhere in the code (which I believe is regarded as bad practice, anyway). Nothing that can't be fixed with a [ 0], anyway.

2457
Announcements / Re: Changes
« on: December 07, 2009, 08:27:32 PM »
Gimme back my HLP and stop asking for administrative confirmation for each mouse movement. It gripes every time I open Code::Blocks.

I do like the home button, though, which behaves differently on OS X.

2458
Announcements / Re: Changes
« on: December 07, 2009, 08:13:32 PM »
I think Chrome just wants a width-height parameter.

And yeah, in actuality, I can name far worse operating systems. Namely, Vista. But I figured stylistically it'd just be better to call it that and take he heat later.

2459
Tips, Tutorials, Examples / Re: draw_healthbar() function
« on: December 07, 2009, 02:42:36 PM »
Glad you liked ENIGMA. ^_^

Anyway, the function looks sound, aside from a few things I'd const.
Code: [Select]
        int Rl,Gl,Bl,Rh,Gh,Bh;
        Rh = __GETR(maxcol);
        Gh = __GETG(maxcol);
        Bh = __GETB(maxcol);
        Rl = __GETR(mincol);
        Gl = __GETG(mincol);
        Bl = __GETB(mincol);
        Rl = (int)(Rl + ((Rh-Rl)*(amount/100)));
        Gl = (int)(Gl + ((Gh-Gl)*(amount/100)));
        Bl = (int)(Bl + ((Bh-Bl)*(amount/100)));

I would make that snippet
Code: [Select]
        const int
        Rh = __GETR(maxcol),
        Gh = __GETG(maxcol),
        Bh = __GETB(maxcol),
        RL = __GETR(mincol),
        GL = __GETG(mincol),
        BL = __GETB(mincol);
        const int
        Rl = (int)(RL + ((Rh-RL)*(amount/100))),
        Gl = (int)(GL + ((Gh-GL)*(amount/100))),
        Bl = (int)(BL + ((Bh-BL)*(amount/100)));

The compiler would probably take care of all that anyway, even if left inline, so it doesn't really matter.
Come to think of it, that's probably the most efficient code I've had submitted. (Sorry, Retro. I won't hold frac() against you)/

Oh, one more thing. Your switch statement. Find out which direction GM defaults.

I'm personally tickled to see another someone's taken interest in the program, especially one that knows some C++. (Or, perhaps is brave enough to use GML knowledge to make a C++ function).

Out of curiosity, are you working with the code that comes with R3 or the code from the SVN repo? Judging by the __, I'd say it's the R3 version. In either case... When I get home, I'll take a closer look at your function and see about incorporating it into R4. I'll credit your current username for it; if you want it under a different name, let me know.

(And yes, those of you who are elitist and don't consider one function a significant contribution, I know it's not much relative to the entire project. However, it's nothing to sneeze at, and if we had 900 more people like Revel, the project would be done already.)

2460
Tips, Tutorials, Examples / Re: A Few Alternate Functions
« on: December 06, 2009, 09:42:14 PM »
Ah, you inputted the zero along with it. Try without the zero.