Server Help

ASSS Questions - Help Ani With His Duel Module

Animate Dreams - Fri Feb 29, 2008 1:14 pm
Post subject: Help Ani With His Duel Module
I'm trying to write a duel module for AS3 again. I haven't done a ton of actually handling the duels, which I think is gonna be hard since I'll have to check for things like lagouts, warp outs, shipchanges, and keeping up with multiple possibilities for rulesets, but that's not what I'm worried about yet.

Here's my actual problem. The module needs to be aware of the existence of duel boxes. But since not everyone uses the same map, I need to have a way to read where the boxes are. And not everyone is going to have the same number of duel boxes. So I figured the best way to store duel boxes would be to have a struct DuelBox and store the coordinates in there. I'll need at least 4 coordinates, upper left corner X and Y, lower right corner X and Y. Then I can read in a list of coordinates from a .conf file when the module is attached, and store them in a linked list of DuelBoxes.

But I don't know how to read an indiscriminant amount of data from a .conf file. I mean, I can have something like:

[DuelBoxes]
UpperLeftX = 432
UpperLeftY = 392
LowerRightX = 239
LowerRightX=299

, but that's only one box. I don't know how I'd use the config module to read in anything but pre-determined keys. I suppose I could just read the .conf file myself through a file reader, but I would much rather be able to just read from arena settings, if that's possible. I'm sure anyone else who did anything to the module would prefer that as well. Besides, it might even be possible to read settings that are in the same format as MERV uses for its duel plugins, so that users wouldn't even have to change the settings files for it to work with AS3... that would be nice, if it's possible.

So does anyone have a solution to this problem? I think I've explained everything. It's also just occured to me that it might be possible to use regions for this. That would also let me easily support duel boxes that weren't box shaped, I think. But I don't know much about regions... last time I did something with regions, I think I remember it not being fast enough to work well for everything. For example, I would be worried about someone leaving the region for only a split second and it not getting counted. I really don't remember if that was the problem I had with regions, or not. Anyway, if any of you have any suggestions of what to do or things to look at, I would appreciate it.
Dr Brain - Fri Feb 29, 2008 2:27 pm
Post subject:
What's wrong with regions?

If you absolutely must use the config do something like:

[Duel]
Boxes = 4
Box0 = ...
Box1 = ...
Box2 = ...
Box3 = ...


pseudo code:

Read boxcount
for (boxcount)
{
sprintf(buffer, "Box%dProperty", i)
property = cfg->get("Duel", buffer)
}
Animate Dreams - Fri Feb 29, 2008 9:35 pm
Post subject:
I imagine nothing is wrong with regions other than what I mentioned(Like I said, I think I remember having issues with the response time when dealing with regions), except that I don't know much about them. I can learn, but since I only thought about them while creating this topic, I didn't exactly have time. Anyway, I was wondering if it was possible(er, should that be "were"? it doesn't seem like it would, but it also seems like it would fall under "condition contrary to fact") to do something like you're doing with sprintf, but I didn't even know how to word it. But you have "Box0 = "... can you just write all 4 coords on one line and read them that way? I was thinking about that, too.

Anyway, I guess I'll look into regions, since you seem to be hinting that it would be the best way.
Dr Brain - Fri Feb 29, 2008 11:09 pm
Post subject:
You'd have the same response problems with a rectangle based system. Packets only come in every so often.

What's wrong with the following?
Box0X1 = ...
Box0Y1 = ...
Box0X2 = ...
Box0Y2 = ...
Smong - Sun Mar 02, 2008 11:17 am
Post subject:
Animate Dreams wrote:
can you just write all 4 coords on one line and read them that way?
You can shove all the coords into one setting and read it using sscanf:
Code: Show/Hide
sscanf(s, "%d , %d , %d , %d", &x1, &y1, &x2, &y2);
The extra spaces between everything accounts for 0 or more characters of white space.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group