Obligatory "I ruined everything!" thread - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Obligatory "I ruined everything!" thread (/thread-476.html) |
RE: Obligatory "I ruined everything!" thread - Lapayo - 07-12-2012 Ahh ... You´re right.. That´s a good point. But there must be another solution, I really hate these lines RE: Obligatory "I ruined everything!" thread - Lapayo - 07-12-2012 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. RE: Obligatory "I ruined everything!" thread - xoft - 07-12-2012 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. RE: Obligatory "I ruined everything!" thread - xoft - 07-28-2012 (07-12-2012, 04:46 AM)Lapayo Wrote: But there must be another solution, I really hate these lines 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 RE: Obligatory "I ruined everything!" thread - FakeTruth - 08-23-2012 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 |