Files
@ r9464:ce84e83c962a
Branch filter:
Location: cpp/openttd-patchpack/source/src/newgrf_townname.cpp - annotation
r9464:ce84e83c962a
3.3 KiB
text/x-c
(svn r13384) -Update: WebTranslator2 update to 2008-06-05 08:15:43
brazilian_portuguese - 9 fixed, 6 changed by tucalipe (15)
catalan - 9 fixed by arnaullv (9)
croatian - 13 fixed by knovak (13)
czech - 33 fixed by Hadez (33)
danish - 47 fixed by ThomasA (47)
dutch - 9 fixed by habell (9)
estonian - 42 fixed, 5 changed by kristjans (47)
finnish - 5 fixed, 1 changed by kerba (6)
french - 9 fixed, 2 changed by glx (8), belugas (3)
icelandic - 75 fixed by scrooge (75)
italian - 9 fixed, 12 changed by lorenzodv (21)
korean - 76 fixed, 15 changed by leejaeuk5 (91)
portuguese - 7 fixed by izhirahider (7)
romanian - 97 fixed, 302 changed by CrystyB (399)
russian - 12 fixed by Smoky555 (12)
spanish - 12 fixed by eusebio (12)
swedish - 13 fixed by ChrillDeVille (6), daishan (7)
turkish - 39 fixed, 1 changed by jnmbk (40)
ukrainian - 10 fixed by mad (10)
brazilian_portuguese - 9 fixed, 6 changed by tucalipe (15)
catalan - 9 fixed by arnaullv (9)
croatian - 13 fixed by knovak (13)
czech - 33 fixed by Hadez (33)
danish - 47 fixed by ThomasA (47)
dutch - 9 fixed by habell (9)
estonian - 42 fixed, 5 changed by kristjans (47)
finnish - 5 fixed, 1 changed by kerba (6)
french - 9 fixed, 2 changed by glx (8), belugas (3)
icelandic - 75 fixed by scrooge (75)
italian - 9 fixed, 12 changed by lorenzodv (21)
korean - 76 fixed, 15 changed by leejaeuk5 (91)
portuguese - 7 fixed by izhirahider (7)
romanian - 97 fixed, 302 changed by CrystyB (399)
russian - 12 fixed by Smoky555 (12)
spanish - 12 fixed by eusebio (12)
swedish - 13 fixed by ChrillDeVille (6), daishan (7)
turkish - 39 fixed, 1 changed by jnmbk (40)
ukrainian - 10 fixed by mad (10)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r8130:bece2e5c7460 r8214:9a3935f9ef4e r6956:6398843f1341 r8264:d493cb51fe8a r8264:d493cb51fe8a r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r7928:a80e7e05d6c5 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r7928:a80e7e05d6c5 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 r6956:6398843f1341 | /* $Id$ */
/** @file newgrf_townname.cpp
* Implementation of Action 0F "universal holder" structure and functions.
* This file implements a linked-lists of townname generators,
* holding everything that the newgrf action 0F will send over to OpenTTD.
*/
#include "stdafx.h"
#include "openttd.h"
#include "newgrf_townname.h"
#include "core/alloc_func.hpp"
#include "string_func.h"
#include "table/strings.h"
static GRFTownName *_grf_townnames = NULL;
GRFTownName *GetGRFTownName(uint32 grfid)
{
GRFTownName *t = _grf_townnames;
for (; t != NULL; t = t->next) {
if (t->grfid == grfid) return t;
}
return NULL;
}
GRFTownName *AddGRFTownName(uint32 grfid)
{
GRFTownName *t = GetGRFTownName(grfid);
if (t == NULL) {
t = CallocT<GRFTownName>(1);
t->grfid = grfid;
t->next = _grf_townnames;
_grf_townnames = t;
}
return t;
}
void DelGRFTownName(uint32 grfid)
{
GRFTownName *t = _grf_townnames;
GRFTownName *p = NULL;
for (;t != NULL; p = t, t = t->next) if (t->grfid == grfid) break;
if (t != NULL) {
for (int i = 0; i < 128; i++) {
for (int j = 0; j < t->nbparts[i]; j++) {
for (int k = 0; k < t->partlist[i][j].partcount; k++) {
if (!HasBit(t->partlist[i][j].parts[k].prob, 7)) free(t->partlist[i][j].parts[k].data.text);
}
free(t->partlist[i][j].parts);
}
free(t->partlist[i]);
}
if (p != NULL) {
p->next = t->next;
} else {
_grf_townnames = t->next;
}
free(t);
}
}
static char *RandomPart(char *buf, GRFTownName *t, uint32 seed, byte id, const char *last)
{
assert(t != NULL);
for (int i = 0; i < t->nbparts[id]; i++) {
byte count = t->partlist[id][i].bitcount;
uint16 maxprob = t->partlist[id][i].maxprob;
uint32 r = (GB(seed, t->partlist[id][i].bitstart, count) * maxprob) >> count;
for (int j = 0; j < t->partlist[id][i].partcount; j++) {
byte prob = t->partlist[id][i].parts[j].prob;
maxprob -= GB(prob, 0, 7);
if (maxprob > r) continue;
if (HasBit(prob, 7)) {
buf = RandomPart(buf, t, seed, t->partlist[id][i].parts[j].data.id, last);
} else {
buf = strecat(buf, t->partlist[id][i].parts[j].data.text, last);
}
break;
}
}
return buf;
}
char *GRFTownNameGenerate(char *buf, uint32 grfid, uint16 gen, uint32 seed, const char *last)
{
strecpy(buf, "", last);
for (GRFTownName *t = _grf_townnames; t != NULL; t = t->next) {
if (t->grfid == grfid) {
assert(gen < t->nb_gen);
buf = RandomPart(buf, t, seed, t->id[gen], last);
break;
}
}
return buf;
}
StringID *GetGRFTownNameList()
{
int nb_names = 0, n = 0;
for (GRFTownName *t = _grf_townnames; t != NULL; t = t->next) nb_names += t->nb_gen;
StringID *list = MallocT<StringID>(nb_names + 1);
for (GRFTownName *t = _grf_townnames; t != NULL; t = t->next) {
for (int j = 0; j < t->nb_gen; j++) list[n++] = t->name[j];
}
list[n] = INVALID_STRING_ID;
return list;
}
void CleanUpGRFTownNames()
{
while (_grf_townnames != NULL) DelGRFTownName(_grf_townnames->grfid);
}
uint32 GetGRFTownNameId(int gen)
{
for (GRFTownName *t = _grf_townnames; t != NULL; t = t->next) {
if (gen < t->nb_gen) return t->grfid;
gen -= t->nb_gen;
}
/* Fallback to no NewGRF */
return 0;
}
uint16 GetGRFTownNameType(int gen)
{
for (GRFTownName *t = _grf_townnames; t != NULL; t = t->next) {
if (gen < t->nb_gen) return gen;
gen -= t->nb_gen;
}
/* Fallback to english original */
return SPECSTR_TOWNNAME_ENGLISH;
}
|