Obligatory "I ruined everything!" thread
#21
Ahh ...
You´re right.. That´s a good point.
But there must be another solution, I really hate these linesBig Grin
Reply
Thanks given by:
#22
I had a little idea:
We could at least use a pair of functions:
e.g.: cEntity * cWorld::LockEntity(...)
and void *cWorld::ReleaseEntity(...)
Or do it via an easy, selfmade lock object, which only calls the worlds entity lock.
Reply
Thanks given by:
#23
Pair of functions - not good, someone will forget the lock locked somewhere and no-one will find it. With RAII, someone could still forget the locking completely.
The point of an API is to be safe whoever wants to call whatever. Windows API, too, doesn't say "you need to lock the filesystem, only then you can call the FileOpen function", it does the locking in itself, when needed. That's the point of the entire API - hide the locking from the "users". In this case "users" = other programmers using that API.
Pity that we don't have C++11 yet, we could use lambda functions as the callbacks, and you'd be happy. But trust me, this is the best possible way.
Reply
Thanks given by:
#24
(07-12-2012, 04:46 AM)Lapayo Wrote: But there must be another solution, I really hate these linesBig Grin

That's right, those lines are pain to write for simple things. That's why I was planning on adding a few utility functions for the usual actions done with objects. So you'd actually call World->EntityTakeDamage(EntityID, DamageAmount); and it would internally use the callback mechanism. Didn't get around to writing this yet, though.

This would be especially good for Lua, so that plugins don't need to write those callbacks too often. Lua people get weirded out by them Wink
Reply
Thanks given by:
#25
I removed cWebPlugin_Lua and cPlugin_NewLua now inherits cWebPlugin. This means a Lua plugin is a web plugin by default.

Plugin:CreateWebPlugin() is now deprecated/obsolete
Now plugins need to call Plugin:AddWebTab() to add a tab instead of WebPlugin:AddTab()
AddTab() is marked deprecated/obsolete
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)