Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

almostkorean posted:

Now I'm having trouble modeling how the gas pedal should work. The simulator I have calculates RPMs, and I'm basically using a percentage of how far the pedal is pushed in to tell how much the RPMs should increase. This works for when you want to accelerate quickly, but how can I make it more like a real automatic car, where your RPMs "level out" when you leave the pedal at the same spot? If anyone can point me in the right direction it would be much appreciated

You could try something like:

rpm += (maxRpm*pedal% - rpm)*timestep/tau

where maxRpm is the fastest RPM possible with the pedal pushed all the way down, pedal% is the percent of full range between 0.0 (pedal not pushed at all) and 1.0 (pedal pushed to the floor). Tau is just a weighting factor that you will need to experiment with that determines how fast the RPM can go up or down to get realistic behavior. Try setting tau=1.0 and adjust from there.

It's just an exponential rise/fall, similar to what Fecotourist was getting at I think.

Adbot
ADBOT LOVES YOU

almostkorean
Jul 9, 2001
eeeeeeeee

PDP-1 posted:

You could try something like:

rpm += (maxRpm*pedal% - rpm)*timestep/tau

where maxRpm is the fastest RPM possible with the pedal pushed all the way down, pedal% is the percent of full range between 0.0 (pedal not pushed at all) and 1.0 (pedal pushed to the floor). Tau is just a weighting factor that you will need to experiment with that determines how fast the RPM can go up or down to get realistic behavior. Try setting tau=1.0 and adjust from there.

It's just an exponential rise/fall, similar to what Fecotourist was getting at I think.

Thanks, this worked perfectly. I used this and made tau a constant which was my "gear ratio" since this is supposed to handle like a 4-speed automatic. My project is coming together nicely, so thanks again to everyone that has helped

Vandorin
Mar 1, 2007

by Fistgrrl
I'm not sure if this is the right place to ask this but, what language are the old Pokemon games made with? Like Pokemon red and blue, are those c++ or a custom language developed by Nintendo?

Vizin
Sep 3, 2007

Vandorin posted:

I'm not sure if this is the right place to ask this but, what language are the old Pokemon games made with? Like Pokemon red and blue, are those c++ or a custom language developed by Nintendo?

I did some googling and couldn't find much about gameboy games, but most people seem to think NES games were written in assembly. I'm guessing that means Gameboy classic games were too.

As someone with no assembly experience, that's a scary thought.

Vandorin
Mar 1, 2007

by Fistgrrl

Vizin posted:

I did some googling and couldn't find much about gameboy games, but most people seem to think NES games were written in assembly. I'm guessing that means Gameboy classic games were too.

As someone with no assembly experience, that's a scary thought.

If I wanted to make a top down game like the Pokemon games, what language do you think would be best?

GROVER CURES HOUSE
Aug 26, 2007

Go on...

Vandorin posted:

If I wanted to make a top down game like the Pokemon games, what language do you think would be best?

Pretty sure there is a C compiler hanging around. But the correct answer is still "you don't".

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Vandorin posted:

If I wanted to make a top down game like the Pokemon games, what language do you think would be best?

Whatever language you know best. (If the answer to that is "none", you probably aren't going to be making Pokemon anytime soon.)

Vandorin
Mar 1, 2007

by Fistgrrl

Avenging Dentist posted:

Whatever language you know best. (If the answer to that is "none", you probably aren't going to be making Pokemon anytime soon.)

I just wanted to know if there was a preferred/easiest language to do this in that I could start learning. So far I only know some C++ and java.

Vizin
Sep 3, 2007

Vandorin posted:

If I wanted to make a top down game like the Pokemon games, what language do you think would be best?

Pretty much any language under the sun these days would be fine for making a Pokemon-like game. The only reason the originals were written in ASM were because the original gameboy hardware was from 1989 and very limited by modern standards. Hell, you could do it in Javascript if you wanted to.

I would suggest using Java. Java's 2D drawing classes are much less painful to learn than SDL or OpenGL.

BizarroAzrael
Apr 6, 2006

"That must weigh heavily on your soul. Let me purge it for you."

Vandorin posted:

If I wanted to make a top down game like the Pokemon games, what language do you think would be best?

A tile-based, top-down 2D game? In pretty much anything you pleased, from Flash upwards.

haveblue
Aug 15, 2005



Toilet Rascal
I suggest Prolog

newsomnuke
Feb 25, 2007

The best language for coding tile-based games in would be Piet, considering that the language itself is tile-based.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Vandorin posted:

I just wanted to know if there was a preferred/easiest language to do this in that I could start learning. So far I only know some C++ and java.

You should be able to do this in Java with fairly little pain, if you already know how it works. Some experience with how to design software in general is more useful than knowing how any specific language works -- but if you don't know how to do that yet, programming a game is a great way to learn.

almostkorean
Jul 9, 2001
eeeeeeeee
I gots a problem. I'm loading a texture onto a rectangle but when I use SetTexture() it makes the other triangles I'm drawing black:


Click here for the full 1025x828 image.


Click here for the full 1029x848 image.


The triangles should look like they are in the bottom pic. As you can see I commented out the SetTexture() line in that second image to get the triangles to show up. Any ideas? I'm calling SetTexture every time the frame is rendered, is that incorrect?

Contero
Mar 28, 2004

Vizin posted:

I would suggest using Java. Java's 2D drawing classes are much less painful to learn than SDL or OpenGL.

What? SDL is fantastic. You only need like 7 calls to get an entire OpenGL program running. It's like the beautiful middle ground between the ugliness of glut and win32.

Here I made you a tile based game using SDL in 33 lines. There's only one tile though. And it's white.

code:
#include <SDL.h>
#include <GL/glut.h>

int main (int argc, char *argv[])
{
   const SDL_VideoInfo* info;
   SDL_Event ev;

   if ( (SDL_Init(SDL_INIT_VIDEO) < 0) || (info = SDL_GetVideoInfo()) == 0 
    || SDL_SetVideoMode(1024, 768, info->vfmt->BitsPerPixel, SDL_OPENGL) == 0)
      return 0;

   glClearColor( 0.45, 0.60, 0.92, 0 );
   glViewport(0, 0, 1024, 768);

   while ( (SDL_PollEvent(&ev), ev.type != SDL_QUIT) && !SDL_GetKeyState(0)[SDLK_ESCAPE] ) {
      glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluPerspective(45.0, (float)1024 /768, 0.0, 128.0);
      gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0);

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      glTranslatef(0.0, 0.0, 3.0);
      glutSolidCube(1.0);

      SDL_GL_SwapBuffers( );
   }

   SDL_Quit();
   return 0;
}
I'll grant you OpenGL being a pain in the rear end though.

Contero fucked around with this message at 01:07 on Nov 21, 2009

wlievens
Nov 26, 2006
General question: I'm doing an isometric game, but my artwork sucks. I'm considering looking for goons that can do iso art (see Goontower and such projects) for a small fee. What forum on SA would be most appropriate for asking for this kind of poo poo? I don't want to get in trouble for inappropriate posting :-)

Drox
Aug 9, 2007

by Y Kant Ozma Post
If you're offering money, post in SAMart, there are always artists of all kinds who do cheap work there.

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug

almostkorean posted:

I gots a problem. I'm loading a texture onto a rectangle but when I use SetTexture() it makes the other triangles I'm drawing black:
I'm assuming this is DirectX. You have to disable texturing for objects you don't want textured - because you haven't specified a different texture to use, it is continuing to use that same tachometer texture for every other object, and since the texture coordinates are not properly specified on the triangles you draw after the gauge, it's just using a corner texel (which is black).

Try doing SetTexture(n, NULL) after you draw the gauge, where n is whatever texture unit you used. The same thing will happen in OpenGL (not sure about XNA).

Seat Safety Switch fucked around with this message at 20:48 on Nov 21, 2009

GROVER CURES HOUSE
Aug 26, 2007

Go on...

Seat Safety Switch posted:

I'm assuming this is DirectX. You have to disable texturing for objects you don't want textured - because you haven't specified a different texture to use, it is continuing to use that same tachometer texture for every other object, and since the texture coordinates are not properly specified on the triangles you draw after the gauge, it's just using a corner texel (which is black).

Try doing SetTexture(n, NULL) after you draw the gauge, where n is whatever texture unit you used. The same thing will happen in OpenGL (not sure about XNA).

AFAIK you can't do that in XNA, you have to explicitly specify a texture and it's position in the draw call.

e: I am a terrible programmer and know next to nothing about graphics, take this with a handful of salt.

Triarii
Jun 14, 2003

I'm making a 2D top-down RTS game using Direct3D for rendering, and I'm trying to figure out how I want to draw shadows for my buildings. Right now each building (which is just a sprite) has a separate shadow sprite to go along with it, which is just a black shape drawn at 50% opacity next to the building such that it looks like the building's shadow, like this:



This works pretty well but it's possible to place a particularly tall building (with a long shadow) next to a smaller building such that their shadows overlap. This makes the overlapped portion darker than the rest of the shadow, like so:



...when really I want it to look like this:



Any ideas on how I can go about achieving that? I feel like I want to draw all of my shadows to one surface and then render that surface at 50% opacity, or something along those lines, but I'm pretty new at Direct3D and I wouldn't know how to do something like that. I am also open to the possibility that there are far superior ways to do this and I'm going about it all the wrong way.

LordNova
Apr 17, 2005

Mayakashi posted:

I'm making a 2D top-down RTS game using Direct3D for rendering, and I'm trying to figure out how I want to draw shadows for my buildings. Right now each building (which is just a sprite) has a separate shadow sprite to go along with it, which is just a black shape drawn at 50% opacity next to the building such that it looks like the building's shadow, like this:



This works pretty well but it's possible to place a particularly tall building (with a long shadow) next to a smaller building such that their shadows overlap. This makes the overlapped portion darker than the rest of the shadow, like so:



...when really I want it to look like this:



Any ideas on how I can go about achieving that? I feel like I want to draw all of my shadows to one surface and then render that surface at 50% opacity, or something along those lines, but I'm pretty new at Direct3D and I wouldn't know how to do something like that. I am also open to the possibility that there are far superior ways to do this and I'm going about it all the wrong way.

Look into using the stencil buffer. Basically, clear the stencil buffer in your clear call to zero, set a stencil reference value of 0, set your stencil pass to pass when the stencil buffer equals that reference value, and then set your stencil pass operation to increment. This ensures that a screen space fragment is written to only once.

TheMarsVoltaire
Jun 16, 2008
Does anyone know what the legality of porting Super Munchers to a modern platform would be? From my research it seems as if MECC's original proof of copyright was lost during the years of it being bought and sold between different companies, but I don't know if that even matters.

Vietnom nom nom
Oct 24, 2000
Forum Veteran

quote:

Does anyone know what the legality of porting Super Munchers to a modern platform would be? From my research it seems as if MECC's original proof of copyright was lost during the years of it being bought and sold between different companies, but I don't know if that even matters.

That depends on a host of issues, but basically it's a bad idea. First of all, I'm assuming you're in the U.S.. Copyright is maintained even if you lose the registration papers. If the original owning company was purchased, the new company retains the copyrights, if the original company went into bankruptcy, intellectual property along with other assets generally go to the creditors (who may auction them off or sell them if they have any value).

Your best bet is to make a clone that changes the surface aspects of the game, while mimicking its gameplay. Otherwise you run the risk of getting sued. I'll admit that a small project like that would be unlikely to draw the attention of whoever still owns the copyright, but it's kind of silly to sink your time and effort into something that might have to be tossed out, or at least overhauled, if you happen to get a legal letter in the mail one day.

wlievens
Nov 26, 2006

Drox posted:

If you're offering money, post in SAMart, there are always artists of all kinds who do cheap work there.


Allright; I made this awesome post:

http://forums.somethingawful.com/showthread.php?threadid=3231860

Triarii
Jun 14, 2003

LordNova posted:

Look into using the stencil buffer. Basically, clear the stencil buffer in your clear call to zero, set a stencil reference value of 0, set your stencil pass to pass when the stencil buffer equals that reference value, and then set your stencil pass operation to increment. This ensures that a screen space fragment is written to only once.

Do you know if the stencil buffer can be used with the D3DXSprite interface? I'm using that to do all of my rendering, and I'm playing around with the stencil-related render states but not seeing any actual change on screen. For instance, if I set the comparison function to D3DCMP_NEVER, I should never see anything rendered to the screen, right?

I noticed that the call to ID3DXSprite::Begin sets D3DRS_STENCILENABLE to false, so I tried moving my SetRenderState calls to after the call to Begin, but that doesn't seem to have made a difference.

Edit: Okay, setting the EnableAutoDepthStencil presentation parameter to true makes the stencil states take effect, but it hugely screws up my alpha blending. It looks like every partially transparent pixel displays the backbuffer color behind it, rather than whatever textures were rendered in back of it.

Edit again: It looks like setting D3DRS_ZENABLE to false disables the depth buffer but still lets me use the stencil buffer, thus solving all my problems.

Triarii fucked around with this message at 23:20 on Nov 22, 2009

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Contero posted:

Here I made you a tile based game using SDL in 33 lines. There's only one tile though. And it's white.

code:
:words:
I'll grant you OpenGL being a pain in the rear end though.

For some reason playing with this combined with the SDL reference and Red Book have gotten me farther along in OpenGL than anything else I've tried.

I've upgraded your tile to a cube and added controls to spin it :v:

BizarroAzrael
Apr 6, 2006

"That must weigh heavily on your soul. Let me purge it for you."

Mayakashi posted:

I'm making a 2D top-down RTS game using Direct3D for rendering, and I'm trying to figure out how I want to draw shadows for my buildings. Right now each building (which is just a sprite) has a separate shadow sprite to go along with it, which is just a black shape drawn at 50% opacity next to the building such that it looks like the building's shadow, like this:



This works pretty well but it's possible to place a particularly tall building (with a long shadow) next to a smaller building such that their shadows overlap. This makes the overlapped portion darker than the rest of the shadow, like so:



...when really I want it to look like this:



Any ideas on how I can go about achieving that? I feel like I want to draw all of my shadows to one surface and then render that surface at 50% opacity, or something along those lines, but I'm pretty new at Direct3D and I wouldn't know how to do something like that. I am also open to the possibility that there are far superior ways to do this and I'm going about it all the wrong way.

This has inspired me. I want to put together a little RTS sort of thing with isometric 2D graphics, but with much of the setting in built up areas where buildings would get in the way of seeing what units are doing between them. This makes me think I can do it top down and still give it depth enough to not look assy.

If only Red Alert 3 was as easy to mod as RA2...

Evil Trout
Nov 16, 2004

The evilest trout of them all
Does anyone know any really good tutorials about network programming for games? When I google it, I keep finding resources that are too basic or too general.

I'm interested in things like packet design, typical problems and how to overcome them, lots of sample source (language doesn't matter so much to me at this point.)

Or hell, any articles on the subject you just really enjoyed. Thanks!

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Evil Trout posted:

Does anyone know any really good tutorials about network programming for games? When I google it, I keep finding resources that are too basic or too general.
The quake network protocol pages always make for interesting reading.

edit: another one which looks promising but I haven't yet read

Evil Trout
Nov 16, 2004

The evilest trout of them all

Dijkstracula posted:

The quake network protocol pages always make for interesting reading.

edit: another one which looks promising but I haven't yet read

Wow thanks for this. The quake packet format is really good reading.

Kennedy
Aug 1, 2006


hard to breathe?
Has anyone got any good links to a A* pathfinding guide? Specifically the data structures used, I know it's nodes and priority queues, but I'm having trouble trying to create them myself.

Triarii
Jun 14, 2003

Kennedy posted:

Has anyone got any good links to a A* pathfinding guide? Specifically the data structures used, I know it's nodes and priority queues, but I'm having trouble trying to create them myself.

I built my pathfinding system almost entirely from this tutorial: http://www.policyalmanac.org/games/aStarTutorial.htm

It also goes into making a binary heap for your priority queue. I just used a two dimensional array for my nodes and used the current coordinates +/- 1 in each direction for the adjacent nodes, but I could see something like a node class with a list of pointers to adjacent nodes working just as well for more irregular play areas.

This page was also useful when I started to refine my system to work a bit more smoothly and efficiently: http://www-cs-students.stanford.edu/~amitp/gameprog.html#paths

Kennedy
Aug 1, 2006


hard to breathe?

Mayakashi posted:

I built my pathfinding system almost entirely from this tutorial: http://www.policyalmanac.org/games/aStarTutorial.htm

It also goes into making a binary heap for your priority queue. I just used a two dimensional array for my nodes and used the current coordinates +/- 1 in each direction for the adjacent nodes, but I could see something like a node class with a list of pointers to adjacent nodes working just as well for more irregular play areas.

This page was also useful when I started to refine my system to work a bit more smoothly and efficiently: http://www-cs-students.stanford.edu/~amitp/gameprog.html#paths

I must have read that page a thousand times before, but it finally clicked today. I have pathfinding finally!

The only problem is that it calculates the path once, but won't recalculate for a new destination if the player moves (the pathing basically follows the player around the map). I'm using XNA, so A* is implemented in enemy.update(), but even if I pass in the player's current node as the destination, it won't recalculate. Anyone got any ideas?

Here's the code
code:
public void performPathing(Node playerNode)
        {

            if (this.currentNode != null && playerNode != null && !foundTarget)
            {
                // add the starting node to the open list
                if (!openList.Contains(currentNode))
                    selectedNode = currentNode;
                selectedNode.onOpenList = true;
                selectedNode.onClosedList = false;
                openList.Add(this.selectedNode);

                while (!closedList.Contains(playerNode))
                {
                    // look for the lowest F cost square on open list, and set as selected
                    openList.Sort();
                    selectedNode = openList[0];

                    // now switch it to the closed list


                    foreach (Node node in selectedNode.adjList)
                    {
                        if (!closedList.Contains(selectedNode))
                        {
                            closedList.Add(selectedNode);
                            openList.Remove(selectedNode);
                            selectedNode.onOpenList = false;
                            selectedNode.onClosedList = true;
                        }

                        if (node.passable && node != null && node.onOpenList == false && node.onClosedList == false)
                        {
                            openList.Add(node);
                            node.onOpenList = true;
                            node.onClosedList = false;
                            node.parent = selectedNode;
                            node.h = calculateH(node, playerNode);
                            node.g = calculateG(node, selectedNode) + node.parent.g;
                            node.f = node.h + node.g;
                        }
                        else if (node.passable && node != null && node.onOpenList == true)
                        {
                            if (node.g < selectedNode.g && node.h < selectedNode.h)
                            {
                                node.parent = selectedNode;
                                selectedNode = node;
                            }

                        }
                    }
                }

                if (closedList.Contains(playerNode))
                {
                    foundTarget = true;
                    path.Add(playerNode);
                    nextNodeInPath = playerNode.parent;
  
                    path.Add(nextNodeInPath);

                    while (nextNodeInPath.parent != currentNode)
                    {
                        path.Add(nextNodeInPath.parent);
                        nextNodeInPath = nextNodeInPath.parent;
                    }

                }                
            }
        }

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Sounds dumb but make sure the node being passed into that function actually is the player's node.

Kennedy
Aug 1, 2006


hard to breathe?
Got it sorted, I wasn't resetting the bools for OnOpenList / OnClosedList for the nodes, so it couldn't recalculate a valid path, and needed to clear out the Path node list before I recalculated again.

Thanks guys!

http://www.youtube.com/watch?v=QgfIeLjPaOY

Kennedy fucked around with this message at 20:11 on Nov 27, 2009

dogmaan
Sep 13, 2007
what do you guys think of SFML?

http://www.sfml-dev.org/

I am using SFML and Lua to create a 2d Platformer, it seems like a good alternative to SDL as sprites are handled in hardware so scaling and rotation is easy and fast

I'm using SFML for openGL, Input, Sound, etc

And Lua for the app & level initialization scripts <- this bit is pissing me off, loving lua stack, interfacing lua with c++ is like trying to pierce my ear with a spoon.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Dijkstracula posted:

The quake network protocol pages always make for interesting reading.

edit: another one which looks promising but I haven't yet read
A lot of things are missing from that, that's mainly the negotiation and reliability protocol.

An example of a few details of Quake 3's implementation:

The client is always displaying a transition between two frames which are BEHIND the current time, with the delay adjusted such that when the current time on the client reaches the second frame, there will be another frame ready from the server to transition to.

Entities are delta encoded with a previous state, which means it tries to only send things that have CHANGED about an entity from a previous state. All objects are checked against visibility optimization, if the server doesn't think a client can see an entity, it will not send it. Quake 2 attempts to delta from the previous frame, and if it detects that a frame was dropped, it tries to recover by deltaing from the last confirmed frame, or possibly just resends a complete state. Quake 3 always sends deltas from the last confirmed state, which causes an increase in traffic, but also means that the client doesn't have to wait for the server to acknowledge a frame drop before it starts getting usable frames again, making dropped frames more benign.

Some entity movement is encoded as a trajectory rather than a position, trajectories being a start time, a start position, velocity, and acceleration. This means most projectiles rarely change the information they send to the server.

The previous point can be utilized in other ways. Quake 3 doesn't have any alternate methods, but as long as the client can predict object behavior, the server only needs to send updates when the prediction is incorrect.

Player movement is a rather messy affair, and there are a LOT of ways to do it. Quake 3 will send movement packets to the server while allowing the client to visibly move, and the server will occasionally send the player's actual location and associated information. The client will have continued appearing to move at this point, but it will check its previous position against the one the server sent, and if they don't match up, it will offset the player's location by the amount that prediction was off by, which has a tendency to converge such that the prediction becomes accurate again.

There are several other quirky things, like predicting ammunition loss and item pickups. I'm not really sure how they work yet though, I'm still looking at it, it appears to be done by tracking an event sequence in the player state, and if that mismatches events relayed back by the server, then it will run the mismatched events.

This system of course requires that players and the rest of the world be run asynchronously, which isn't always doable, especially with physics systems that hate running at variable framerates. For those, there's an alternative approach, which is to have the server buffer user input and run it a few frames late. This tends to accentuate lag though (hello BF2!)

For lag compensation, there are two basic systems: Either trust the client, i.e. client says "I shot this player in the head" and see if perhaps a head shot would be currently viable, and if it is then treat it as a shot to the target's head. The other more common method is "rewinding" the world to when the shot was fired to see what it would have hit then.

Hope that clears things up a bit.

OneEightHundred fucked around with this message at 16:29 on Nov 28, 2009

Vinterstum
Jul 30, 2003

dogmaan posted:

what do you guys think of SFML?

http://www.sfml-dev.org/

I am using SFML and Lua to create a 2d Platformer, it seems like a good alternative to SDL as sprites are handled in hardware so scaling and rotation is easy and fast

I'm using SFML for openGL, Input, Sound, etc

And Lua for the app & level initialization scripts <- this bit is pissing me off, loving lua stack, interfacing lua with c++ is like trying to pierce my ear with a spoon.

If you think doing the Lua interface directly is too low-level, you could always go with Luabind or SWIG or one of the other wrappers out there.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
If you want to make writing Lua entry points easier, one thing you could do is use call IDs and make a single engine entry point. For example, my current project does this:

code:
local native = function(sysCallID)
	local callID = sysCallID
	local sysCallFunc = syscall

	return function(...)
		return sysCallFunc(callID, ...)
	end
end

...

trace = native(6)
Doing that allows you to use one entry point (syscall, in this case) with the first parameter being the function ID. Also doing as much as possible in Lua instead of C++ will make your life much easier.

You can also use the standard library function "xpcall" to handle stack tracing more elegantly as well. See here for simple "invoke" functions that take a function (and its arguments in the case of traceInvokeV) and call it, throwing an error containing stack info if it fails:

http://icculus.org/~riot/invoke.lua

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Vinterstum posted:

If you think doing the Lua interface directly is too low-level, you could always go with Luabind or SWIG or one of the other wrappers out there.

Luabind is cool if you want Lua to look more like "traditional" (Simula-style) OO, but I've begun to question the applicability of that, even though I've worked on patches for Luabind.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply