11 Feb, 2013, Rarva.Riendf wrote in the 21st comment:
Votes: 0
err I formatted the code in my editor and found this kind stuff numerous time as well

if (victim->light_cavalry >= 1 && (chdam > LCAV_HP))
; //<——————

won't do anything, so what is the point.

sprintf(buf, "%d Trebuchets, ", chfighting);
stc(buf, victim);
sprintf(buf, "%d Trebuchets, ", chfighting);
stc(buf, ch);


What it the point in duplicating the sprtinf as well ?
11 Feb, 2013, quixadhal wrote in the 22nd comment:
Votes: 0
I think the "point" is that the author of the code doesn't actually understand how it works, and is just copying wholesale chunks and moving them around until they look like they should do what he wants.
11 Feb, 2013, Rarva.Riendf wrote in the 23rd comment:
Votes: 0
Well that was already clear from the first post…people not understanding why they have high negative values when they use positive ones means they dont understand much about how a computer works :) Just trying to make him look at his code and not just blindingly move stuff around till it seems it works.
13 Feb, 2013, Xrakisis wrote in the 24th comment:
Votes: 0
i rewrote the army system and its running pretty smooth..

army rounds…

[Your army is attacked and takes :6827968 damage]

[Your army of: 85000 attacks Their army of:67010]



[You deal 15487968 damage against their armies 284901910 Total Health
[Your Army damage: 15487968]

the command..

[code]void battle_update( void )
{
CHAR_DATA *ch;
CHAR_DATA *ch_next;
CHAR_DATA *victim;
CHAR_DATA *rch;
CHAR_DATA *rch_next;
DESCRIPTOR_DATA *d;
char buf[MAX_STRING_LENGTH];
int chance;
int armymight = 0;
int varmymight = 0;
int roundtime;
int totalfighting = 0;
int vtotalfighting = 0;
unsigned long int chfighting = 0;
int vfighting = 0;
int distance;
chance = number_percent();
unsigned long int x, y, dam;
unsigned long int chdam = 0;
unsigned long int vlife = 0;



for (ch = first_fight; ch != NULL; ch = ch_next)
{
ch_next = ch->next_fight;

if ((victim = ch->fighting) == NULL || ch->in_room == NULL)
{
stop_fighting (ch, FALSE);
continue;
}
if ((victim = ch->fighting) == NULL)
{
stop_fighting (ch, FALSE);
continue;
}

totalfighting = ch->militia;
totalfighting += ch->pikemen;
totalfighting += ch->swordsmen;
totalfighting += ch->heavy_infantry;
totalfighting += ch->axemen;
totalfighting += ch->archers;
totalfighting += ch->archerinfantry;
totalfighting += ch->chariots;
totalfighting += ch->light_cavalry;
totalfighting += ch->medium_cavalry;
totalfighting += ch->heavy_cavalry;
totalfighting += ch->knights;
totalfighting += ch->ballistas;
totalfighting += ch->catapults;
totalfighting += ch->rams;
totalfighting += ch->scorpions;
totalfighting += ch->trebuchets;

vtotalfighting = victim->militia;
vtotalfighting += victim->pikemen;
vtotalfighting += victim->swordsme
vtotalfighting += victim->heavy_infantry;
vtotalfighting += victim->axemen;
vtotalfighting += victim->archers;
vtotalfighting += victim->archerinfantry;
vtotalfighting += victim->chariots;
vtotalfighting += victim->light_cavalry;
vtotalfighting += victim->medium_cavalry;
vtotalfighting += victim->heavy_cavalry;
vtotalfighting += victim->knights;
vtotalfighting += victim->ballistas;
vtotalfighting += victim->catapults;
vtotalfighting += victim->rams;
vtotalfighting += victim->scorpions;
vtotalfighting += victim->trebuchets;


if (totalfighting <= 0 || vtotalfighting <= 0) return;

chdam += ch->militia * MILITIA_ATTACK;
chdam += ch->pikemen * PIKEMAN_ATTACK;
chdam += ch->swordsmen * SWORDSMAN_ATTACK;
chdam += ch->heavy_infantry * HINF_ATTACK;
chdam += ch->axemen * AXEMAN_ATTACK;
chdam += ch->archers * ARCHER_ATTACK;
chdam += ch->archerinfantry * ARCHERINF_ATTACK;
chdam += ch->chariots * CHARIOT_ATTACK;
chdam += ch->light_cavalry * LCAV_ATTACK;
chdam += ch->medium_cavalry * MCAV_ATTACK;
chdam += ch->heavy_cavalry * HCAV_ATTACK;
chdam += ch->knights * KNIGHT_ATTACK;
chdam += ch->ballistas * BALLISTA_ATTACK;
chdam += ch->catapults * CATAPULT_ATTACK;
chdam += ch->rams * RAM_ATTACK;
chdam += ch->scorpions * SCORPION_ATTACK;
chdam += ch->trebuchets * TREBUCHET_ATTACK;

vlife += victim->militia * MILITIA_HP;
vlife += victim->pikemen * PIKEMAN_HP;
vlife += victim->swordsmen * SWORDSMAN_HP;
vlife += victim->heavy_infantry * HINF_HP;
vlife += victim->axemen * AXEMAN_HP;
vlife += victim->archers * ARCHER_HP;
vlife += victim->archerinfantry * ARCHERINF_HP;
vlife += victim->chariots * CHARIOT_HP;
vlife += victim->light_cavalry * LCAV_HP;
vlife += victim->medium_cavalry * MCAV_HP;
vlife += victim->heavy_cavalry * HCAV_HP;
vlife += victim->knights * KNIGHT_HP;
vlife += victim->ballistas * BALLISTA_HP;
vlife += victim->catapults * CATAPULT_HP;
vlife += victim->rams * RAM_HP;
vlife += victim->scorpions * SCORPION_HP;
vlife += victim->trebuchets * TREBUCHET_HP;



sprintf(buf,"\n\r[#yYour army of: #R%d#n attacks #yTheir army of:#R%d]\n\r", totalfighting, vtotalfighting);
stc(buf,ch);
sprintf(buf,"\n\r[#yYou deal %d damage against their armies %d Total Health\n\r", chdam, vlife);
stc(buf,ch);

sprintf(buf,"[#yYour Army damage: #R%d#n]\n\r",chdam);
stc(buf,ch);
sprintf(buf,"[#yYour army is attacked and takes :#R%d#Y damage#n]\n\r",chdam);
stc(buf,victim);


}

int n;
for (n=1; n < chdam; n++)
{
if (chdam > CHARIOT_HP && victim->chariots >= 1)
{ victim->chariots–;
chdam -= CHARIOT_HP;}
if (chdam > HCAV_HP && victim->heavy_cavalry >= 1)
{ victim->heavy_cavalry–;
chdam -= HCAV_HP;}
if (chdam > KNIGHT_HP && victim->knights >= 1)
{ victim->knights–;
chdam -= KNIGHT_HP;}
if (chdam > MCAV_HP && victim->medium_cavalry >= 1)
{ victim->medium_cavalry–;
chdam -= MCAV_HP;}
if (chdam > LCAV_HP && victim->light_cavalry >= 1)
{ victim->light_cavalry–;
chdam -= LCAV_HP;}
if (chdam > PIKEMAN_HP && victim->pikemen >= 1)
{ victim->pikemen–;
chdam -= PIKEMAN_HP;}
if (chdam > RAM_HP && victim->rams >= 1)
{ victim->rams–;
chdam -= RAM_HP;}
if (chdam > HINF_HP && victim->heavy_infantry >= 1)
{ victim->heavy_infantry–;
chdam -= HINF_HP;}
if (chdam > SWORDSMAN_HP && victim->swordsmen >= 1)
{ victim->swordsmen–;
chdam -= SWORDSMAN_HP;}
if (chdam > AXEMAN_HP && victim->axemen >= 1)
{ victim->axemen–;
chdam -= AXEMAN_HP;}
if (chdam > MILITIA_HP && victim->militia >= 1)
{ victim->militia–;
chdam -= MILITIA_HP;}
if (chdam > ARCHERINF_HP && victim->archerinfantry >= 1)
{ victim->archerinfantry–;
chdam -= ARCHERINF_HP;}
if (chdam > ARCHER_HP && victim->archers >= 1)
{ victim->archers–;
chdam -= ARCHER_HP;}
if (chdam > SCORPION_HP && victim->scorpions >= 1)
{ victim->scorpions–;
chdam -= SCORPION_HP;}
if (chdam > BALLISTA_HP && victim->ballistas >= 1)
{ victim->ballistas–;
chdam -= BALLISTA_HP;}
if (chdam > CATAPULT_HP && victim->catapults >= 1)
{ victim->catapults–;
chdam -= CATAPULT_HP;}
if (chdam > TREBUCHET_HP && victim->trebuchets >= 1)
{ victim->trebuchets–;
chdam -= TREBUCHET_HP;}

}

return;

}
[/code]

i changed the army stuff from pc_data to char data a while ago
and the hero mobs that randomly load have armies..
13 Feb, 2013, Telgar wrote in the 25th comment:
Votes: 0
I facepalmed at the \n\r.
13 Feb, 2013, Rarva.Riendf wrote in the 26th comment:
Votes: 0
Changing from \n\r to \r\n is not that trivial. And keeping the way it is on the other hand, is mostly harmless :)
13 Feb, 2013, quixadhal wrote in the 27th comment:
Votes: 0
It is INCREDIBLY trivial.

A simple regexp will change 99% of them, and you can then search your code and data for instances of doubled \r's or doubled \n's to find cases where it messed up because you had an intentional CR or LF next to a pair.

After that, there are the potential cases of your code picking out CR or LF individually.

I did this for my old DikuMUD, around 100K lines of code, in an hour or so. Not that hard unless, of course, you don't actually know your codebase.
13 Feb, 2013, Rarva.Riendf wrote in the 28th comment:
Votes: 0
great it worked for you…..It did not with mine, as there where quite a few modifications in the code that expected a \n\r in that order, and thus checking only for the \r. I started confident it would be as easy as you stated , it was not. (well not hard, but way more work that I wanted to pour in for absolutely no real purpose).
13 Feb, 2013, quixadhal wrote in the 29th comment:
Votes: 0
The real purpose I did mine wasn't to be "correct", but to make anchored triggers in mud clients work properly.

With the correct line endings, a trigger like /^You see/ matches. With it reversed, it won't match because the line will show up (to the client) as "^MYou see…", which means Y isn't the first character, CR is.

So, it's not no real purpose. It's to make your player's mud client triggers actually work the way they're supposed to work.
13 Feb, 2013, Rarva.Riendf wrote in the 30th comment:
Votes: 0
quixadhal said:
So, it's not no real purpose. It's to make your player's mud client triggers actually work the way they're supposed to work.


Provided you have a use for such triggers on my mud. But that was not my point. It is not trivial in all cases, far from it , and if the goal is for a few specific triggers it still has no real purpose. Supporting triggers is not my problem anyway, I like theml as a programmer, as a player, I would prefer not to have to use any to compete, so anything that needed a trigger I ended up coding it in game. I like my players to bea ble to compete on barebone telnet.
13 Feb, 2013, quixadhal wrote in the 31st comment:
Votes: 0
Not all client features are used to cheat Rarva.

I happen to like using triggers to highlight certain events, so my tired old eyes can see them in the flow of spam that happens in most MUD combat systems.
13 Feb, 2013, Rarva.Riendf wrote in the 32nd comment:
Votes: 0
I do not consider trigger as a cheat as well. I do use color to highlight certain events that you can configure in game. A player that would have a need to highlight something else would probably have me code it in game. So everyone could use it, and not only the one that know how to code.
14 Feb, 2013, kiasyn wrote in the 33rd comment:
Votes: 0
are we actually seriously for real arguing over doing something the documented right way or the wrong way?
14 Feb, 2013, Rarva.Riendf wrote in the 34th comment:
Votes: 0
There is no argue about what is right. It is about how easy it is to reverse years of a bad way. And the actual gain beside the good feeling of having it done right. Considering the coding skills of some tinkerer it is even counter productive to ask them to change this.
14 Feb, 2013, Tyche wrote in the 35th comment:
Votes: 0
Telgar said:
I facepalmed at the \n\r.

I did this reading the ensuing argument about how non-trivial it is to fix:
14 Feb, 2013, Rarva.Riendf wrote in the 36th comment:
Votes: 0
Enjoy breaking people code telling them a single string replacement works…
15 Feb, 2013, Tyche wrote in the 37th comment:
Votes: 0
Rarva.Riendf said:
Enjoy breaking people code telling them a single string replacement works…

Bwahahaha!
15 Feb, 2013, Runter wrote in the 38th comment:
Votes: 0
Tyche love breaking people code. Don't trust anyone over 30.
15 Feb, 2013, Tyche wrote in the 39th comment:
Votes: 0
If you're feeling extraordinarily lazy, try stuffing this in your ROM write_to_descriptor() function in comm.c

if ( length <= 0 )
length = strlen(txt);
+ for(iStart=0,nBlock=0;iStart<length;iStart++){if(*(txt+iStart)=='\n'){nBlock=1;continue;}
+ if(*(txt+iStart)=='\r'&&nBlock){*(txt+iStart-1)='\r';*(txt+iStart)='\n';}nBlock=0;}
for ( iStart = 0; iStart < length; iStart += nWrite )
{


Untested, guaranteed to break occasionally, and like…totally trivial.
15 Feb, 2013, Vigud wrote in the 40th comment:
Votes: 0
If I remember correctly, my mud's code didn't like it, so indeed it wasn't as simple as it would seem, but I didn't care to investigate. Feel free to fix it for me, now that its source is public and nobody ever plays the game. https://github.com/Lamieur/Lac
20.0/42