coding with caps.

Discute about general card coding keyword, ask questions and get answer about the mechanism, about the guideline, the direction we want to go...etc...

coding with caps.

Postby Zethfox » Sun Aug 22, 2010 11:01 am

auto=may copy NotATarget(ally)

see all the fancy capital letters in the above line?

every single keyword and ability is coded in lowercase, and coded to look for the words in lower case.
when ever you use caps like this the game has to send the information to get converted to lower case for the parser to read, and something ive noticed is that it sometimes doesnt always activate abilities written as above when multiple things are happening at the same time.

MoveTo(myBattleField) <-- lets try to keep things like this to a minimum, the game would preform better if it didnt have to convert every single line of code in the primitives to lower case everytime the parser tries to read a line.

this is directly from the source code......

if (tc && s.find("notatarget(") != string::npos){
tc->targetter = NULL;
found = found - 4;
}
string temp = s.substr(0,found);
temp.append(s.substr(end+1));
sWithoutTc = temp;
}

see its looks for all lowercase, an i will tell you this much the parser understands lower case perfectly. and it knows the difference between a capital and a lowercase letter, when it finds a cap, it calls another part of wagic code to translate it.
Zethfox
 
Posts: 2788
Joined: Thu Jun 10, 2010 11:28 pm

Re: coding with caps.

Postby Dr.Solomat » Mon Aug 23, 2010 8:54 am

...so, what should we do and what shoud we not do??
Sets Coded/Released: Legends, Visions, Weatherlight, Tempest, Stronghold, Portal I & III, Urza's Saga BLOCK, Mercadian Masques, Invasion BLOCK, Mirrodin, Ravnica, Guildpact, Conflux, Alara Reborn
Dr.Solomat
 
Posts: 975
Joined: Mon Dec 15, 2008 5:12 pm
Location: Germany

Re: coding with caps.

Postby Zethfox » Mon Aug 23, 2010 10:35 am

code this ---->auto=may copy NotATarget(ally)

like this---->auto=may copy notatarget(ally)

instead...
and use "moveto(mybattlefield)" instead of "MoveTo(MyBattleField)"
Zethfox
 
Posts: 2788
Joined: Thu Jun 10, 2010 11:28 pm

Re: coding with caps.

Postby wololo » Mon Aug 30, 2010 2:23 am

I disagree. Tee caps are here for readability. Either way we want to keep backwards compatibility, and the parser being case insensitive was a requirement from the start. I don't know the algorithm, but I don't think it takes less time to convert a string that is all lowercase anyways.
For speed improvements of the parser, we want byte compilation. It's something we discussed a while ago, but unfortunately never implemented.
wololo
Site Admin
 
Posts: 3709
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Advertising


Return to Discussion & Misc

Who is online

Users browsing this forum: No registered users and 1 guest