forked from github/server
Translating the familiar-description and moving some part to documentation.
This commit is contained in:
parent
81a89b8d47
commit
d57e6724d1
|
@ -2083,7 +2083,7 @@ report_plaintext(const char * filename, report_context * ctx)
|
|||
}
|
||||
if (!fval(r->terrain, SEA_REGION)) {
|
||||
if (sh->coast != NODIRECTION) {
|
||||
scat(", ");
|
||||
scat(LOC(f->locale, "list_and"));
|
||||
scat(LOC(f->locale, coasts[sh->coast]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -584,9 +584,7 @@ sp_summon_familiar(castorder *co)
|
|||
|
||||
dh = 0;
|
||||
dh1 = 0;
|
||||
sprintf(buf, "%s ruft einen Vertrauten. %s können ",
|
||||
unitname(mage), LOC(mage->faction->locale, rc_name(rc, 1)));
|
||||
for(sk=0;sk<MAXSKILLS;sk++) {
|
||||
for (sk=0;sk<MAXSKILLS;sk++) {
|
||||
if (rc->bonus[sk] > -5) dh++;
|
||||
}
|
||||
for(sk=0;sk<MAXSKILLS;sk++) {
|
||||
|
@ -596,7 +594,7 @@ sp_summon_familiar(castorder *co)
|
|||
dh1 = 1;
|
||||
} else {
|
||||
if (dh == 0) {
|
||||
scat(" und ");
|
||||
scat(LOC(mage->faction->locale, "list_and"));
|
||||
} else {
|
||||
scat(", ");
|
||||
}
|
||||
|
@ -604,23 +602,8 @@ sp_summon_familiar(castorder *co)
|
|||
scat(skillname(sk, mage->faction->locale));
|
||||
}
|
||||
}
|
||||
scat(" lernen.");
|
||||
scat(" ");
|
||||
scat("Der Vertraute verleiht dem Magier einen Bonus auf jedes Talent ");
|
||||
scat("(ausgenommen Magie), welches der Vertraute beherrscht.");
|
||||
scat(" ");
|
||||
scat("Das spezielle Band zu seinem Vertrauten ermöglicht dem Magier ");
|
||||
scat("auch, Sprüche durch diesen zu wirken. So gezauberte Sprüche ");
|
||||
scat("wirken auf die Region des Vertrauten und brauchen keine Fernzauber ");
|
||||
scat("zu sein. Die maximale Entfernung dafür entspricht dem Talent des ");
|
||||
scat("Magiers. Einen Spruch durch das Vertrautenband zu richten ist ");
|
||||
scat("jedoch gewissen Einschränkungen unterworfen. Die Stufe des Zaubers ");
|
||||
scat("kann nicht größer als das Magietalent des Vertrauten oder das halbe ");
|
||||
scat("Talent des Magiers sein. Auch verdoppeln sich die Kosten für den ");
|
||||
scat("Spruch. (Um einen Zauber durch den Vertrauten zu wirken, gibt ");
|
||||
scat("man statt dem Magier dem Vertrauten den Befehl ZAUBERE.)");
|
||||
|
||||
addmessage(r, mage->faction, buf, MSG_MAGIC, ML_INFO);
|
||||
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
|
||||
"mage race skills", mage, rc, buf));
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,187 +198,185 @@ static const char * parse(opstack **, const char* in, const void *);
|
|||
|
||||
static const char *
|
||||
parse_symbol(opstack ** stack, const char* in, const void * userdata)
|
||||
/* in is the symbol name and following text, starting after the $
|
||||
* result goes on the stack
|
||||
*/
|
||||
/* in is the symbol name and following text, starting after the $
|
||||
* result goes on the stack
|
||||
*/
|
||||
{
|
||||
boolean braces = false;
|
||||
char symbol[32];
|
||||
char *cp = symbol; /* current position */
|
||||
boolean braces = false;
|
||||
char symbol[32];
|
||||
char *cp = symbol; /* current position */
|
||||
|
||||
if (*in=='{') {
|
||||
braces = true;
|
||||
++in;
|
||||
}
|
||||
while (isalnum(*in) || *in=='.') *cp++ = *in++;
|
||||
*cp = '\0';
|
||||
/* symbol will now contain the symbol name */
|
||||
if (*in=='(') {
|
||||
/* it's a function we need to parse
|
||||
* start by reading the parameters
|
||||
*/
|
||||
function * foo;
|
||||
while (*in != ')') {
|
||||
in = parse(stack, ++in, userdata); /* will push the result on the stack */
|
||||
if (in==NULL) return NULL;
|
||||
}
|
||||
++in;
|
||||
foo = find_function(symbol);
|
||||
if (*in=='{') {
|
||||
braces = true;
|
||||
++in;
|
||||
}
|
||||
while (isalnum(*in) || *in=='.') *cp++ = *in++;
|
||||
*cp = '\0';
|
||||
/* symbol will now contain the symbol name */
|
||||
if (*in=='(') {
|
||||
/* it's a function we need to parse, start by reading the parameters */
|
||||
function * foo;
|
||||
while (*in != ')') {
|
||||
in = parse(stack, ++in, userdata); /* will push the result on the stack */
|
||||
if (in==NULL) return NULL;
|
||||
}
|
||||
++in;
|
||||
foo = find_function(symbol);
|
||||
if (foo==NULL) {
|
||||
log_error(("parser does not know about \"%s\" function.\n", symbol));
|
||||
return NULL;
|
||||
}
|
||||
foo->parse(stack, userdata); /* will pop parameters from stack (reverse order!) and push the result */
|
||||
} else {
|
||||
variable * var = find_variable(symbol);
|
||||
if (braces && *in=='}') {
|
||||
++in;
|
||||
}
|
||||
/* it's a constant (variable is a misnomer, but heck, const was taken;)) */
|
||||
foo->parse(stack, userdata); /* will pop parameters from stack (reverse order!) and push the result */
|
||||
} else {
|
||||
variable * var = find_variable(symbol);
|
||||
if (braces && *in=='}') {
|
||||
++in;
|
||||
}
|
||||
/* it's a constant (variable is a misnomer, but heck, const was taken;)) */
|
||||
if (var==NULL) {
|
||||
log_error(("parser does not know about \"%s\" variable.\n", symbol));
|
||||
return NULL;
|
||||
}
|
||||
opush(stack, var->value);
|
||||
}
|
||||
return in;
|
||||
opush(stack, var->value);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
static const char *
|
||||
parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*) -> char* */
|
||||
{
|
||||
char * c;
|
||||
char * buffer = balloc(4*1024);
|
||||
const char * ic = in;
|
||||
char * oc = buffer;
|
||||
/* mode flags */
|
||||
boolean f_escape = false;
|
||||
boolean bDone = false;
|
||||
char * c;
|
||||
char * buffer = balloc(4*1024);
|
||||
const char * ic = in;
|
||||
char * oc = buffer;
|
||||
/* mode flags */
|
||||
boolean f_escape = false;
|
||||
boolean bDone = false;
|
||||
variant var;
|
||||
|
||||
while (*ic && !bDone) {
|
||||
if (f_escape) {
|
||||
f_escape = false;
|
||||
switch (*ic) {
|
||||
case 'n':
|
||||
*oc++='\n';
|
||||
break;
|
||||
case 't':
|
||||
*oc++='\t';
|
||||
break;
|
||||
default:
|
||||
*oc++=*ic;
|
||||
}
|
||||
} else {
|
||||
int ch = (unsigned char)(*ic);
|
||||
switch (ch) {
|
||||
case '\\':
|
||||
f_escape = true;
|
||||
++ic;
|
||||
break;
|
||||
case '"':
|
||||
bDone = true;
|
||||
++ic;
|
||||
break;
|
||||
case '$':
|
||||
ic = parse_symbol(stack, ++ic, userdata);
|
||||
if (ic==NULL) return NULL;
|
||||
c = (char*)opop_v(stack);
|
||||
oc += strlen(strcpy(oc, c));
|
||||
bfree(c);
|
||||
break;
|
||||
default:
|
||||
*oc++=*ic++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*oc++ = '\0';
|
||||
bfree(oc);
|
||||
while (*ic && !bDone) {
|
||||
if (f_escape) {
|
||||
f_escape = false;
|
||||
switch (*ic) {
|
||||
case 'n':
|
||||
*oc++='\n';
|
||||
break;
|
||||
case 't':
|
||||
*oc++='\t';
|
||||
break;
|
||||
default:
|
||||
*oc++=*ic;
|
||||
}
|
||||
} else {
|
||||
int ch = (unsigned char)(*ic);
|
||||
switch (ch) {
|
||||
case '\\':
|
||||
f_escape = true;
|
||||
++ic;
|
||||
break;
|
||||
case '"':
|
||||
bDone = true;
|
||||
++ic;
|
||||
break;
|
||||
case '$':
|
||||
ic = parse_symbol(stack, ++ic, userdata);
|
||||
if (ic==NULL) return NULL;
|
||||
c = (char*)opop_v(stack);
|
||||
oc += strlen(strcpy(oc, c));
|
||||
bfree(c);
|
||||
break;
|
||||
default:
|
||||
*oc++=*ic++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*oc++ = '\0';
|
||||
bfree(oc);
|
||||
var.v = buffer;
|
||||
opush(stack, var);
|
||||
return ic;
|
||||
opush(stack, var);
|
||||
return ic;
|
||||
}
|
||||
|
||||
static const char *
|
||||
parse_int(opstack ** stack, const char * in)
|
||||
{
|
||||
int k = 0;
|
||||
int vz = 1;
|
||||
boolean ok = false;
|
||||
int k = 0;
|
||||
int vz = 1;
|
||||
boolean ok = false;
|
||||
variant var;
|
||||
do {
|
||||
switch (*in) {
|
||||
case '+':
|
||||
++in;
|
||||
break;
|
||||
case '-':
|
||||
++in;
|
||||
vz=vz*-1;
|
||||
break;
|
||||
default:
|
||||
ok = true;
|
||||
}
|
||||
} while (!ok);
|
||||
while (isdigit(*in)) {
|
||||
k = k * 10 + (*in++)-'0';
|
||||
}
|
||||
do {
|
||||
switch (*in) {
|
||||
case '+':
|
||||
++in;
|
||||
break;
|
||||
case '-':
|
||||
++in;
|
||||
vz=vz*-1;
|
||||
break;
|
||||
default:
|
||||
ok = true;
|
||||
}
|
||||
} while (!ok);
|
||||
while (isdigit(*in)) {
|
||||
k = k * 10 + (*in++)-'0';
|
||||
}
|
||||
var.i = k*vz;
|
||||
opush(stack, var);
|
||||
return in;
|
||||
opush(stack, var);
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
parse(opstack ** stack, const char* inn, const void * userdata)
|
||||
{
|
||||
const char * b = inn;
|
||||
while (*b) {
|
||||
switch (*b) {
|
||||
case '"':
|
||||
return parse_string(stack, ++b, userdata);
|
||||
break;
|
||||
case '$':
|
||||
return parse_symbol(stack, ++b, userdata);
|
||||
break;
|
||||
default:
|
||||
if (isdigit(*b) || *b=='-' || *b=='+') {
|
||||
return parse_int(stack, b);
|
||||
}
|
||||
else ++b;
|
||||
}
|
||||
}
|
||||
log_error(("could not parse \"%s\". Probably invalid message syntax.", inn));
|
||||
return NULL;
|
||||
const char * b = inn;
|
||||
while (*b) {
|
||||
switch (*b) {
|
||||
case '"':
|
||||
return parse_string(stack, ++b, userdata);
|
||||
break;
|
||||
case '$':
|
||||
return parse_symbol(stack, ++b, userdata);
|
||||
break;
|
||||
default:
|
||||
if (isdigit(*b) || *b=='-' || *b=='+') {
|
||||
return parse_int(stack, b);
|
||||
}
|
||||
else ++b;
|
||||
}
|
||||
}
|
||||
log_error(("could not parse \"%s\". Probably invalid message syntax.", inn));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
translate(const char* format, const void * userdata, const char* vars, variant args[])
|
||||
{
|
||||
int i = 0;
|
||||
const char *ic = vars;
|
||||
char symbol[32];
|
||||
char *oc = symbol;
|
||||
opstack * stack = NULL;
|
||||
int i = 0;
|
||||
const char *ic = vars;
|
||||
char symbol[32];
|
||||
char *oc = symbol;
|
||||
opstack * stack = NULL;
|
||||
const char * rv;
|
||||
|
||||
brelease();
|
||||
free_variables();
|
||||
free_variables();
|
||||
|
||||
assert(format);
|
||||
assert(*ic == 0 || isalnum(*ic));
|
||||
while (*ic) {
|
||||
*oc++ = *ic++;
|
||||
if (!isalnum(*ic)) {
|
||||
variant x = args[i++];
|
||||
*oc = '\0';
|
||||
oc = symbol;
|
||||
add_variable(strcpy(balloc(strlen(symbol)+1), symbol), x);
|
||||
while (*ic && !isalnum(*ic)) ++ic;
|
||||
}
|
||||
}
|
||||
assert(format);
|
||||
assert(*ic == 0 || isalnum(*ic));
|
||||
while (*ic) {
|
||||
*oc++ = *ic++;
|
||||
if (!isalnum(*ic)) {
|
||||
variant x = args[i++];
|
||||
*oc = '\0';
|
||||
oc = symbol;
|
||||
add_variable(strcpy(balloc(strlen(symbol)+1), symbol), x);
|
||||
while (*ic && !isalnum(*ic)) ++ic;
|
||||
}
|
||||
}
|
||||
|
||||
if (parse(&stack, format, userdata)==NULL) return NULL;
|
||||
rv = (const char*)opop(&stack).v;
|
||||
if (parse(&stack, format, userdata)==NULL) return NULL;
|
||||
rv = (const char*)opop(&stack).v;
|
||||
free(stack->begin);
|
||||
free(stack);
|
||||
return rv;
|
||||
|
|
|
@ -6837,4 +6837,9 @@
|
|||
<text locale="de">bewacht die Region</text>
|
||||
<text locale="en">guards the region</text>
|
||||
</string>
|
||||
|
||||
<string name="list_and">
|
||||
<text locale="de"> und </text>
|
||||
<text locale="en"> and </text>
|
||||
</string>
|
||||
</strings>
|
||||
|
|
|
@ -1704,6 +1704,15 @@
|
|||
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - $unit($mage) kann nicht genug Energie aufbringen, um diesen Spruch durch $unit($unit) zu wirken."</text>
|
||||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $unit($mage) cannot raise enough energy to channel the spell through $unit($unit)."</text>
|
||||
</message>
|
||||
<message name="familiar_describe" section="magic">
|
||||
<type>
|
||||
<arg name="mage" type="unit"/>
|
||||
<arg name="skills" type="string"/>
|
||||
<arg name="race" type="race"/>
|
||||
</type>
|
||||
<text locale="de">"$unit($mage) ruft einen Vertrauten. $race($race, 0) können $skills lernen."</text>
|
||||
<text locale="en">"$unit($mage) summons a familiar. $race($race, 0) can learn $skills."</text>
|
||||
</message>
|
||||
<message name="spell_resist" section="magic">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
|
Loading…
Reference in New Issue