Critical bug in MCServer
#25
Actually I was thinking that the Lua interface objects needn't 100% correspond to MCS internal objects.

I was thinking, how about a (C++) wrapper for let's say the cPlayer, that only stores a pointer to the world (safe - noone deletes the world while the server is running) and the player name. Then every time Lua script attempted an operation on this player, let's say "kick", the Lua interface object would call something like "m_World->KickPlayer(m_PlayerName)". Same with entities - store world pointer and entity ID. Let the world object enumerate all cEntities safely and return an array of "cLuaEntity" classes.

This way we can sustain the current Lua interface with the objects the way there are, with direct functions and even "get all" functions, but in the inside work with the safe interfaces. It would mean a lot of coding, though, and I'm afraid a lot of internal Lua learning, especially about object lifecycle - when to delete objects that were passed out to Lua
(02-15-2012, 05:16 AM)FakeTruth Wrote: It's kinda annoying to use when you can't pass some arbitrary values to the callback

I've seen the code now and I don't know - why can't you? I think the Lua function ForEachPlayer could perfectly take 2 parameters - the function to call and an arbitrary pointer. Store the pointer in the callback class and then call the Lua callback function with that pointer on the stack.
Unfortunately I can't help you implement this, as I have no experience in Lua integration, it's just what I've seen in the code makes me believe that it's possible to do.
Thanks given by:


Messages In This Thread
Critical bug in MCServer - by FakeTruth - 01-01-2012, 02:21 PM
RE: Critical bug in MCServer - by mtilden - 01-01-2012, 11:05 PM
RE: Critical bug in MCServer - by Lapayo - 01-01-2012, 11:47 PM
RE: Critical bug in MCServer - by FakeTruth - 01-02-2012, 12:21 AM
RE: Critical bug in MCServer - by xoft - 02-08-2012, 11:44 PM
RE: Critical bug in MCServer - by FakeTruth - 02-09-2012, 12:23 AM
RE: Critical bug in MCServer - by xoft - 02-09-2012, 03:26 AM
RE: Critical bug in MCServer - by xoft - 02-10-2012, 01:44 AM
RE: Critical bug in MCServer - by FakeTruth - 02-10-2012, 02:05 AM
RE: Critical bug in MCServer - by xoft - 02-10-2012, 07:28 AM
RE: Critical bug in MCServer - by xoft - 02-13-2012, 05:46 AM
RE: Critical bug in MCServer - by tbar - 02-13-2012, 07:53 PM
RE: Critical bug in MCServer - by xoft - 02-14-2012, 07:59 AM
RE: Critical bug in MCServer - by tbar - 02-14-2012, 06:35 PM
RE: Critical bug in MCServer - by xoft - 02-14-2012, 11:10 PM
RE: Critical bug in MCServer - by FakeTruth - 02-14-2012, 09:29 PM
RE: Critical bug in MCServer - by FakeTruth - 02-14-2012, 11:41 PM
RE: Critical bug in MCServer - by xoft - 02-14-2012, 11:53 PM
RE: Critical bug in MCServer - by FakeTruth - 02-15-2012, 12:00 AM
RE: Critical bug in MCServer - by xoft - 02-15-2012, 12:24 AM
RE: Critical bug in MCServer - by FakeTruth - 02-15-2012, 12:38 AM
RE: Critical bug in MCServer - by xoft - 02-15-2012, 03:05 AM
RE: Critical bug in MCServer - by NiLSPACE - 02-15-2012, 03:18 AM
RE: Critical bug in MCServer - by FakeTruth - 02-15-2012, 05:16 AM
RE: Critical bug in MCServer - by xoft - 02-15-2012, 06:36 AM
RE: Critical bug in MCServer - by FakeTruth - 02-15-2012, 07:10 AM
RE: Critical bug in MCServer - by xoft - 02-15-2012, 07:14 AM
RE: Critical bug in MCServer - by FakeTruth - 02-15-2012, 07:26 AM
RE: Critical bug in MCServer - by FakeTruth - 02-15-2012, 11:22 PM
RE: Critical bug in MCServer - by Boo - 02-16-2012, 04:08 PM
RE: Critical bug in MCServer - by xoft - 02-16-2012, 07:37 PM
RE: Critical bug in MCServer - by Boo - 02-16-2012, 08:26 PM
RE: Critical bug in MCServer - by FakeTruth - 02-16-2012, 08:57 PM
RE: Critical bug in MCServer - by Boo - 02-16-2012, 09:32 PM
RE: Critical bug in MCServer - by FakeTruth - 02-16-2012, 09:57 PM



Users browsing this thread: 1 Guest(s)