0.9.4 released

Anything else to do with MoM IME
Locked
User avatar
Implode
Site Admin
Posts: 433
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

0.9.4 released

Post by Implode »

If anybody is still alive here, 0.9.4 can now be downloaded from Sourceforge :)

I realise this has been a very, very long time since I last released an update, especially considering on the outside it isn't terriblly different from 0.9.3. The only major new feature is that you can now set the Units Fog of War setting to "Remember as Last Seen". But thinking back over everything that's gone on since then, I can at least understand myself why its taken this long, and to me that's one key feature that's a really, really big deal. So if anyone's interested, going to give some background here :)

I was struggling by the end of 0.9.3, there were some significant issues with the way the code was in Delphi that couldn't easily be addressed:
  • Memory allocation/deallocation in Delphi is really tedious, you have to do everything by hand, free everything by hand, be very careful not to leave references to freed objects lying around, otherwise you get "Access Violation" errors all over the place.
  • That limits some things you can do. In particular while I managed to have the server remember n copies of the building, spell, city and terrain data (that is, it knows not only the "true" values, but it remembers how the city looked the last time player 1 saw it, and the last time player 2 saw it, which may be quite different). But the data structures for units were too complex to replicate n times. It was going to be impossible to allow units to be "Remember as Last Seen", and without that impossible to write any kind of sensible overland map AI.
  • The data model was haphazard, with items declared here and there - collating it all into a single data store to allow saved game files would have been incredibly difficult, and was a feature people kept asking for.
  • I had attempted to allow it to be multithreaded, so the server could process messages from multiple players at once. But once a lot of the code was done, I realised this was a farce - practically EVERY update requires locking the list of players, and EVERY update requires locking the map terrain. So, all that happens is the threads all sit locked while they execute and complete one at a time. Meaning I was putting a huge amount of effort into carefully ensuring all memory reads/writes were locked and threadsafe, with no benefit from it.
  • I had people ask, interested to help on the project, but Delphi just isn't widely used.
So, I started trying to port the server over to Java. Sadly, we learn by our mistakes, and my mistake was to try to port it exactly as it was, locking semantics and all, and try to exactly replicate the network messages sent between the server and client. Looking back, while I knew how to code in Java at the time, I just didn't have enough experience to understand how to *think* in Java, I just viewed it as, Delphi is an OO language, Java is an OO language, you approach things the same way. So I was converting it pretty much line by line.

2 years into this, I realised I was getting nowhere. I was spending 90% of my time writing mundane code to read/write data files, and read/write network messages, to match what Delphi did, and 10% doing something actually interesting and useful. Moreover, I was precisely copying over the locking code so it could still attempt to be multithreaded, even knowing it was pointless, because I knew I had to do *something* to stop thread collisions when network messages from different players are arriving in different threads, and I just didn't know any better way to do it. So I realised for all my effort I really wasn't going to be much better off than I was with the Delphi code, the conversion was a pointless effort but I felt the Delphi code was at a dead end too, so not knowing what else to do, I gave up and trashed everything I'd done on the Java port.

A good amount more time passed, during which time I started working a lot more with web services, CXF and Maven at my day job. What I really liked about web services was that you didn't have to write any of the plumbing code - you just write a WSDL/XSD schema detailing the inputs/outputs of each service, and the various plugins would automatically create all the Java stubs to match those data structures for you, and do all the converting of XML>objects and objects>XML for you invisibly, leaving you to be able to concentrate on only the useful bits.

That really got me thinking, why can't I do the same thing with MoM IME. With some digging, I found with an xsd2java plugin and JAXB I could create all the Java stubs for all the data objects, and read in the whole XML file in about 3 lines of code - previously, I'd been months slogging through code to parse the server XML. Then I started to think, why can't I do the same for the network messages, so I'm not spending ages writing code to push/read those down the network - I mean, I know I can't use web services directly because they're restricted that they're always invoked from the client-side (the server can't initiate a call out to the client). But why couldn't I take all the useful bits of this, and just write my own wrapping protocol around it that meant the calls could be bi-directional?

So, I tried it. I modelled all the multiplayer network messages (not the MoM-specific stuff, just like, Log In, Create Game, Join Game, Leave Game). Then had some "fun" trying to figure out how to open network sockets and shove XML messages down them in both directions, keeping the connection open between messages. But I got it to work. The light blub also went on about how I could solve the multithreading issues - it did't matter if the network messages *arrive* on different threads, if I just wrote something to pull them out of those threads and be *processed* on a single thread - then if only one thread is ever accessing the game data, I don't need to screw around thread locking it at all, just all the data is open to all of the code - and it made everything so blindingly easy.

For a Java solution it felt perfect. The issue was, since I didn't want to try to port both the server and client to Java in one hit (would have taken forever), I had to get the old Delphi client to talk in XML down the network. I didn't know if that was even feasible, I mean, Delphi 7 is outdated now, XML was around at the time but not in heavy usage. There's a component and libraries included for it, but I didn't know how workable it was. So getting this to work was interesting to say the least, but managed. It was some legwork going through every single network message converting the old protocol into XML, but just worked through this as I implemented the same parts into the Java server.

And, after various other delays, hiccups and so on, finally got there.

So, from here on, if people find significant bugs in 0.9.4 (i.e. crashes game) then I'll do bugfix releases for these like 0.9.4.1, 0.9.4.2, and so on. But majorly I'll start looking at porting the client over to Java for 0.9.5. Handling the graphics makes me shudder how I'm going to do that in Java, I really have no experience in that. But at least all the XML handling and data model and all the network messages are all already done before I even start :)
Worsas
Posts: 12
Joined: Sat Jun 16, 2007 8:15 pm

Re: 0.9.4 released

Post by Worsas »

Tested it. I can confirm that both server and client work for me after following your directions in the readme file. I really love the amount of customizability of everything.

I made a small testmap where I got stuck upon trying to cast Phantom Warriors in combat. I tried to make the phantom warriors summon in front of the enemy beyond where they can be usually placed in combat since the spellhand showed up on each field. First the phantom warriors did not appear. But the combat could not be continued anylonger, too. When giving commands to my units, they were not executed anymore. I could not flee nor cast further spells either but still switch between units.

I got this output in the server console that may be relevant.
https://dl.dropboxusercontent.com/u/223 ... llcast.png

I'm looking forward to the java client later. The day I will be able to play a fully functioning and customized game with my older sister and my brothers will be great. Seriously, it will be amazing to be able to play against smart players in this game that are able to do all those wicked things that you usually only do yourself.
User avatar
Implode
Site Admin
Posts: 433
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Re: 0.9.4 released

Post by Implode »

Yeah "UnsupportedOperationException" like that is what I put in place for code that just isn't written yet, although, I wonder if it existed in the Delphi server and was something I missed out in the conversion... will look into, thanks for posting it. I admit I kind of rushed the last 2 weeks at it because was just getting sick of finding one-more-thing-to-be-done and just wanted to get it finished + out there :)
User avatar
Implode
Site Admin
Posts: 433
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Re: 0.9.4 released

Post by Implode »

Released 0.9.4.1 on SourceForge, can now cast spells in combat. This used to work in 0.9.3 and in doing the Java conversion of the server it got put in the "complicated, do that later" pile and then... forgotten about. So thanks for finding it and letting me know.

Enchantments (like prayer) work; combat summons (like phantom warriors) work; enchantments (like holy weapon) and curses (like warp creature) work although the effects of the skills in many cases doesn't work, so it'll give you a skill icon that doesn't do much.

Have noticed as well that the sounds/graphics are a bit off in places, e.g. ranged attacked use melee sword sound and don't display the animation of the shot hitting the target. Since the client is being rewritten anyway and it doesn't break anything, I just didn't bother to spend ages trying to find out why this is messing up. A lot of the client side animation queuing is really complicated and I didn't wan't to get stuck into trying to debug it when I've got more useful things to be doing instead!
User avatar
Implode
Site Admin
Posts: 433
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Re: 0.9.4 released

Post by Implode »

Found minor bug: If you pick Sss'ra as wizard or pick custom and choose the Myrran retort, it won't let you pick a Myrran race. I'm not going to bother doing a new build just to fix that but if someone else finds something major (i.e. that crashes the game or makes it unplayable) then I'll fix this as well then.
Lupinedreams
Posts: 83
Joined: Tue Jul 25, 2006 6:40 pm

Re: 0.9.4 released

Post by Lupinedreams »

Just wanted to chime in with support! I remember being excited about this many years ago, and it looks like things are shaping up to be more playable. Congratulations on the breakthrough!
stew
Posts: 8
Joined: Wed Mar 28, 2007 10:54 pm

Re: 0.9.4 released

Post by stew »

I was hoping that I'd see Implode continue to make MOM for modern computers. I just stopped in to see what was happening. Very good! Glad it's still going.
User avatar
Implode
Site Admin
Posts: 433
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Re: 0.9.4 released

Post by Implode »

Thanks, nice to know people are still alive out there. It doesn't help that I had to disable new registrations on the forum again because otherwise I'm spending 30 mins a day just delete crap spam posts, but that's bad because then anybody new and genuinely interested in the project can't join the forum.

Anyway yes I'm slogging through it, been putting a real effort in over the last month, but just everything takes so long. To do one decent looking screen takes about a week, mostly fighting with layout managers because I'm trying to do things that are just counter-intuitive to the way Swing is intended to work. You're supposed to not care about exactly where components are placed, so the layout manager can move and resize things around appropriately. But everything in MoM has custom backgrounds, and more often than not the text/buttons/etc then have to line up precisely over the background image, so I'm half the time butchering the layout manager trying to get it to place things exactly where they need to be (which was sadly so easy in Delphi, I'd just give it coordinates to place the component at and it was that easy).

Now been trying to do what sounds like it should be fairly simple, to do labels with shadows and borders. But no matter what I try it always seems to work *nearly* right but not just right, and trying to make things like that look exactly how I want just eats up so much time. But I try not to get too frustrated at it to the point that I feel like giving up. So, still lots of progress being made. Am trying to work on being able to move units from the Java client now, that's a really big piece. If I can get that working and the whole turn sequence then I'd start to feel like the Java client is getting close to being something usable :)
stew
Posts: 8
Joined: Wed Mar 28, 2007 10:54 pm

Re: 0.9.4 released

Post by stew »

That's a shame that no new users can be created right now. Hang in there. From what it sounds like you have a long road ahead of you on that client. I want to show this game off to some of my friends, but I think I'll wait until you give the go-ahead on that client of yours.
Locked