11 Oct, 2012, Sorressean wrote in the 1st comment:
Hello all: Im curious if there are people that wouldnt mind taking a poke through my current code to make suggestions on how I could clean things up and make it better. Essentially the problem right now is Ive got about 16k lines of code, which isnt all that much; I started on a custom base because a lot of my ideas are sort of unique, and I didnt want to have to find Diku and rip all the magic code out, and I dont want to be bound by a Diku license. I really want to be able to accept donations to help pay for the server, and I cant do that with the Diku license. So I started writing my base from scratch building off the SocketMud engine so I wouldnt have to write a bunch of extra networking code. It wasnt all that much code to begin with, but Im greatful for not having to do the networking portions, at least some of it. As I mentioned though, I am running into some major issues.
The biggest problem is trying to find some way to handle object creation. Right now I have two main classes, Entity and StaticObject. The idea was that StaticObjects could be created by builders, and their zone would be the zone the builder was in when they created the object. The object would have all the editing done to it, like the addition of components and what not, then when an object was created, it would copy the static object and that would be that. This leads me to a few issuesIm not exactly sure how Id handle identification of these objects. Each static object would have a vnum, and I guess I could just use an unsigned long long int and hwen the mud shut down along with other persistent data I could store the maximum vnum number that Id grab and increase whenever a new object was created. This leaves me to keeping track of the static object vnum, room vnums, and actual in-game object vnums. Any other ideas for handling this would be really appreciated.
I honestly started this as an open source barebones engine, but I ended up pulling it so I could just start adding my own code and working on the mud aspect of it. I think the biggest hurtles for me right now is the object creation and OLC, and then I should (hopefully) be set. Thanks,
This leads me to a few issuesIm not exactly sure how Id handle identification of these objects.
There are a few threads floating around here with interesting discussion about object ids, so it'd be worth it to look those up. I've found Google searches on the mudbytes.net domain to be the best. Anyway, my advice here is to keep it simple. Give all objects a unique id. Save them with the object data. Store references to other objects by their unique id. You don't have to only use this id in the player-facing interface. But for internal server use, keep it simple, give everything a unique id. This can just be an incrementing number from the first time the mud starts up.