faction *gm_addfaction(const char *email, plane * p, region * r) { attrib *a; unit *u; faction *f = calloc(1, sizeof(faction)); assert(p != NULL); /* GM faction */ a_add(&f->attribs, make_key(atoi36("quest"))); f->banner = _strdup("quest faction"); f->name = _strdup("quest faction"); f->passw = _strdup(itoa36(rng_int())); if (set_email(&f->email, email) != 0) { log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email); } f->race = new_race[RC_TEMPLATE]; f->age = 0; f->lastorders = turn; f->alive = true; f->locale = default_locale; f->options = want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN); { faction *xist; int id = atoi36("gm00") - 1; do { xist = findfaction(++id); } while (xist); f->no = id; addlist(&factions, f); fhash(f); } /* generic permissions */ a = a_add(&f->attribs, a_new(&at_permissions)); if (a) { attrib *ap = (attrib *) a->data.v; const char *keys[] = { "gmterf", "gmtele", "gmgive", "gmskil", "gmtake", "gmmsgr", "gmmsgu", "gmgate", 0 }; const char **key_p = keys; while (*key_p) { add_key(&ap, atoi36(*key_p)); ++key_p; } a_add(&ap, make_atgmcreate(resource2item(r_silver))); a->data.v = ap; } /* one initial unit */ u = create_unit(r, f, 1, new_race[RC_TEMPLATE], 1, "quest master", NULL); u->irace = new_race[RC_GNOME]; return f; }
faculty::faculty(string new_name, string new_image, string new_email, BD new_birthday, unsigned int new_id, member_type new_type, string new_web) { set_name(new_name); set_image(new_image); set_email(new_email); set_birthday(new_birthday); set_id(new_id); set_type(new_type); set_web(new_web); }
staff::staff( string new_name, string new_image, string new_email, BD new_birthday, unsigned int new_id, member_type new_type, int new_phoneNumber ) { set_name(new_name); set_image(new_image); set_email(new_email); set_birthday(new_birthday); set_id(new_id); set_type(new_type); set_phoneNumber(new_phoneNumber); }
void Person::MergeFrom(const Person& from) { GOOGLE_CHECK_NE(&from, this); phone_.MergeFrom(from.phone_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { set_name(from.name()); } if (from.has_id()) { set_id(from.id()); } if (from.has_email()) { set_email(from.email()); } } mutable_unknown_fields()->append(from.unknown_fields()); }
static void guardian_faction(plane * pl, int id) { region *r; faction *f = findfaction(id); if (!f) { f = calloc(1, sizeof(faction)); f->banner = _strdup("Sie dienen dem großen Wyrm"); f->passw = _strdup(itoa36(rng_int())); set_email(&f->email, "*****@*****.**"); f->name = _strdup("Igjarjuks Kundschafter"); f->race = new_race[RC_ILLUSION]; f->age = turn; f->locale = find_locale("de"); f->options = want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN) | want(O_DEBUG); f->no = id; addlist(&factions, f); fhash(f); } if (f->race != new_race[RC_ILLUSION]) { assert(!"guardian id vergeben"); exit(0); } f->lastorders = turn; f->alive = true; for (r = regions; r; r = r->next) if (getplane(r) == pl && rterrain(r) != T_FIREWALL) { unit *u; freset(r, RF_ENCOUNTER); for (u = r->units; u; u = u->next) { if (u->faction == f) break; } if (u) continue; u = createunit(r, f, 1, new_race[RC_GOBLIN]); set_string(&u->name, "Igjarjuks Auge"); set_item(u, I_RING_OF_INVISIBILITY, 1); set_order(&u->thisorder, NULL); fset(u, UFL_ANON_FACTION); set_money(u, 1000); } }
DictInfo& DictInfo::operator=(const DictInfo& dict_info) { clear(); ifo_file_name = dict_info.ifo_file_name; if(dict_info.is_wordcount()) set_wordcount(dict_info.get_wordcount()); if(dict_info.is_filecount()) set_filecount(dict_info.get_filecount()); if(dict_info.is_synwordcount()) set_synwordcount(dict_info.get_synwordcount()); if(dict_info.is_bookname()) set_bookname(dict_info.get_bookname()); if(dict_info.is_author()) set_author(dict_info.get_author()); if(dict_info.is_email()) set_email(dict_info.get_email()); if(dict_info.is_website()) set_website(dict_info.get_website()); if(dict_info.is_date()) set_date(dict_info.get_date()); if(dict_info.is_description()) set_description(dict_info.get_description()); if(dict_info.is_index_file_size()) set_index_file_size(dict_info.get_index_file_size()); if(dict_info.is_sametypesequence()) set_sametypesequence(dict_info.get_sametypesequence()); if(dict_info.is_dicttype()) set_dicttype(dict_info.get_dicttype()); if(dict_info.is_version()) set_version(dict_info.get_version()); if(dict_info.is_infotype()) set_infotype(dict_info.get_infotype()); f_idxoffsetbits = dict_info.f_idxoffsetbits; return *this; }
bool DictInfo::load_from_ifo_file(const std::string& ifofilename, DictInfoType infotype) { clear(); ifo_file_name=ifofilename; set_infotype(infotype); glib::CharStr buffer; glib::Error error; if (!g_file_get_contents(ifo_file_name.c_str(), get_addr(buffer), NULL, get_addr(error))) { g_critical("Load %s failed. Error: %s.", ifo_file_name.c_str(), error->message); return false; } const gchar *p1 = get_impl(buffer); if(g_str_has_prefix(p1, UTF8_BOM)) p1 += 3; if(!g_utf8_validate(p1, -1, NULL)) { g_critical("Load %s failed: Invalid UTF-8 encoded text.", ifo_file_name.c_str()); return false; } lineno = 1; const gchar *magic_data = NULL; if(infotype == DictInfoType_NormDict) magic_data = NORM_DICT_MAGIC_DATA; else if(infotype == DictInfoType_TreeDict) magic_data = TREE_DICT_MAGIC_DATA; else if(infotype == DictInfoType_ResDb) magic_data = RES_DB_MAGIC_DATA; else return false; if (!g_str_has_prefix(p1, magic_data)) { g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str()); if(g_str_has_prefix(p1, NORM_DICT_MAGIC_DATA)) g_message("File '%s' is an index-based dictionary.", ifo_file_name.c_str()); else if(g_str_has_prefix(p1, TREE_DICT_MAGIC_DATA)) g_message("File '%s' is a tree dictionary.", ifo_file_name.c_str()); else if(g_str_has_prefix(p1, RES_DB_MAGIC_DATA)) g_message("File '%s' is a resource database.", ifo_file_name.c_str()); else g_message("File '%s' is not a StarDict dictionary or it's broken.", ifo_file_name.c_str()); return false; } p1 += strlen(magic_data); p1 = skip_new_line(p1); if(!p1) { g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str()); return false; } std::string key, value; while(true) { ++lineno; p1 = get_key_value(p1, key, value); if(!p1) break; // version must the first option if(!is_version()) { if(key != "version") { g_critical("Load %s failed: \"version\" must be the first option.", ifo_file_name.c_str()); return false; } } if(key == "version") { if(!check_option_duplicate(f_version, "version")) continue; set_version(value); if(infotype == DictInfoType_NormDict) { if(version != "2.4.2" && version != "3.0.0") { g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str()); return false; } } else if(infotype == DictInfoType_TreeDict) { if(version != "2.4.2") { g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str()); return false; } } else if(infotype == DictInfoType_ResDb) { if(version != "3.0.0") { g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str()); return false; } } } else if(key == "idxoffsetbits") { if(!check_option_duplicate(f_idxoffsetbits, "idxoffsetbits")) continue; if(value != "32") { // TODO g_critical("Load %s failed: idxoffsetbits != 32 not supported presently.", ifo_file_name.c_str()); return false; } } else if(key == "wordcount" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_wordcount, "wordcount")) continue; set_wordcount(atol(value.c_str())); } else if(key == "filecount" && infotype == DictInfoType_ResDb) { if(!check_option_duplicate(f_filecount, "filecount")) continue; set_filecount(atol(value.c_str())); } else if(key == "synwordcount" && infotype == DictInfoType_NormDict) { if(!check_option_duplicate(f_synwordcount, "synwordcount")) continue; set_synwordcount(atol(value.c_str())); } else if(key == "tdxfilesize" && infotype == DictInfoType_TreeDict) { if(!check_option_duplicate(f_index_file_size, "tdxfilesize")) continue; set_index_file_size(atol(value.c_str())); } else if(key == "idxfilesize" && infotype == DictInfoType_NormDict) { if(!check_option_duplicate(f_index_file_size, "idxfilesize")) continue; set_index_file_size(atol(value.c_str())); } else if(key == "ridxfilesize" && infotype == DictInfoType_ResDb) { if(!check_option_duplicate(f_index_file_size, "ridxfilesize")) continue; set_index_file_size(atol(value.c_str())); } else if(key == "dicttype" && infotype == DictInfoType_NormDict) { if(!check_option_duplicate(f_dicttype, "dicttype")) continue; set_dicttype(value); } else if(key == "bookname" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_bookname, "bookname")) continue; set_bookname(value); } else if(key == "author" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_author, "author")) continue; set_author(value); } else if(key == "email" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_email, "email")) continue; set_email(value); } else if(key == "website" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_website, "website")) continue; set_website(value); } else if(key == "date" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_date, "date")) continue; set_date(value); } else if(key == "description" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_description, "description")) continue; std::string temp; decode_description(value.c_str(), value.length(), temp); set_description(temp); } else if(key == "sametypesequence" && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { if(!check_option_duplicate(f_sametypesequence, "sametypesequence")) continue; set_sametypesequence(value); } else { g_message("Load %s warning: unknown option %s.", ifo_file_name.c_str(), key.c_str()); } } // check required options if((!is_wordcount() || wordcount == 0) && ((infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict))) { g_critical("Load %s failed: wordcount not specified or 0.", ifo_file_name.c_str()); return false; } if((!is_filecount() || filecount == 0) && infotype == DictInfoType_ResDb) { g_critical("Load %s failed: filecount not specified or 0.", ifo_file_name.c_str()); return false; } if((!is_bookname() || bookname.empty()) && (infotype == DictInfoType_NormDict || infotype == DictInfoType_TreeDict)) { g_critical("Load %s failed: bookname not specified.", ifo_file_name.c_str()); return false; } if(!is_index_file_size() || index_file_size == 0) { const char* kkey; if(infotype == DictInfoType_NormDict) kkey = "idxfilesize"; else if(infotype == DictInfoType_TreeDict) kkey = "tdxfilesize"; else if(infotype == DictInfoType_ResDb) kkey = "ridxfilesize"; else kkey = ""; g_critical("Load %s failed: %s not specified or 0.", ifo_file_name.c_str(), kkey); return false; } return true; }
newfaction *read_newfactions(const char *filename) { newfaction *newfactions = NULL; FILE *F = fopen(filename, "r"); char buf[1024]; if (F == NULL) return NULL; for (;;) { faction *f; char race[20], email[64], lang[8], password[16]; newfaction *nf, **nfi; int bonus = 0, subscription = 0; int alliance = 0; if (fgets(buf, sizeof(buf), F) == NULL) break; email[0] = '\0'; password[0] = '\0'; if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus, &subscription, password, &alliance) < 3) break; if (email[0] == '\0') break; if (password[0] == '\0') { size_t sz; sz = strlcpy(password, itoa36(rng_int()), sizeof(password)); sz += strlcat(password, itoa36(rng_int()), sizeof(password)); } for (f = factions; f; f = f->next) { if (strcmp(f->email, email) == 0 && f->subscription && f->age < MINAGE_MULTI) break; } if (f && f->units) continue; /* skip the ones we've already got */ for (nf = newfactions; nf; nf = nf->next) { if (strcmp(nf->email, email) == 0) break; } if (nf) continue; nf = calloc(sizeof(newfaction), 1); if (set_email(&nf->email, email) != 0) { log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email); continue; } nf->password = _strdup(password); nf->race = rc_find(race); nf->subscription = subscription; if (alliances != NULL) { struct alliance *al = findalliance(alliance); if (al == NULL) { char zText[64]; sprintf(zText, "Allianz %d", alliance); al = makealliance(alliance, zText); } nf->allies = al; } else { nf->allies = NULL; } if (nf->race == NULL) { /* if the script didn't supply the race as a token, then it gives us a * race in the default locale (which means that itis a UTF8 string) */ nf->race = findrace(race, default_locale); if (nf->race == NULL) { char buffer[32]; size_t outbytes = sizeof(buffer) - 1; size_t inbytes = strlen(race); unicode_latin1_to_utf8(buffer, &outbytes, race, &inbytes); buffer[outbytes] = 0; nf->race = findrace(buffer, default_locale); if (nf->race == NULL) { log_error("new faction has unknown race '%s'.\n", race); free(nf); continue; } } } nf->lang = get_locale(lang); nf->bonus = bonus; assert(nf->race && nf->email && nf->lang); nfi = &newfactions; while (*nfi) { if ((*nfi)->race == nf->race) break; nfi = &(*nfi)->next; } nf->next = *nfi; *nfi = nf; } fclose(F); return newfactions; }