void load_recipes (){ char fname[128]; FILE *fp; init_recipe_names(); if (recipes_loaded) { /* * save existing recipes instead of loading them if we are already logged in * this will take place when relogging after disconnection */ save_recipes(); return; } recipes_loaded=1; memset (recipes, 0, sizeof (recipes)); safe_snprintf(fname, sizeof(fname), "recipes_%s.dat",username_str); my_tolower(fname); fp = open_file_config(fname,"rb"); if(fp == NULL){ LOG_ERROR("%s: %s \"%s\"\n", reg_error_str, cant_open_file, fname); return; } if (fread (recipes,sizeof(recipes),1, fp) != 1) LOG_ERROR("%s() read failed for file [%s]\n", __FUNCTION__, fname); fclose (fp); load_recipe_names(); }
void load_server_markings(){ char fname[128]; FILE *fp; server_mark sm; int rf; init_server_markers(); //open server markings file safe_snprintf(fname, sizeof(fname), "servermarks_%s.dat",username_str); my_tolower(fname); fp = open_file_config(fname,"r"); if(fp == NULL){ LOG_ERROR("%s: %s \"%s\": %s\n", reg_error_str, cant_open_file, fname, strerror(errno)); return; } while((rf=fscanf(fp,"%d %d %d %s %[^\n]s\n",&sm.id,&sm.x,&sm.y,sm.map_name,sm.text))==5){ server_mark *nm = calloc(1,sizeof(server_mark)); memcpy(nm,&sm,sizeof(server_mark)); hash_add(server_marks,(NULL+sm.id),(void*) nm); } fclose (fp); LOG_DEBUG("Read server markings from file '%s'", fname); add_server_markers(); }
/* save the recipe names, done on exit and after each change */ void save_recipes(){ char fname[128]; FILE *fp; size_t i; if (!recipes_loaded) return; save_recipe_names(); safe_snprintf(fname, sizeof(fname), "recipes_%s.dat",username_str); my_tolower(fname); fp=open_file_config(fname,"wb"); if(fp == NULL){ LOG_ERROR("%s: %s \"%s\": %s\n", reg_error_str, cant_open_file, fname, strerror(errno)); return; } for (i=0; i<num_recipe_entries+1; i++) { item *store = (i<num_recipe_entries) ?recipes_store[i].items :manu_recipe.items; if (fwrite (store,sizeof(item)*NUM_MIX_SLOTS,1, fp) != 1) { LOG_ERROR("%s() fail during write of file [%s] : %s\n", __FUNCTION__, fname, strerror(errno)); break; } } fclose(fp); }
static int ProcessImage( IplImage* image, char* funcname, int read ) { char name[1000]; char lowername[1000]; int i = 0, err; do { lowername[i] = (char)my_tolower(funcname[i]); } while( funcname[i++] != '\0' ); if( read ) { err = CheckImage( image, atsGetTestDataPath(name, filedir_, lowername, "bmp"), funcname ); if( err ) { trsWrite( ATS_CON | ATS_LST, "Error in %s: %d\n", funcname, err ); } return 0; //err; } else { cvvSaveImage( atsGetTestDataPath(name, filedir_, lowername, "bmp"), image ); return 0; } }
/* load saved recipe names from file */ static void load_recipe_names(void) { char fname[128]; FILE *fp; char line [128]; size_t recipe_no; recipe_names_changed = 0; safe_snprintf(fname, sizeof(fname), "recipes_%s.names",username_str); my_tolower(fname); fp = open_file_config(fname,"r"); if(fp == NULL) { LOG_ERROR("%s() %s \"%s\" [%s]\n", __FUNCTION__, cant_open_file, fname, strerror(errno)); return; } recipe_no = 0; while (fgets(line, sizeof(line), fp) != NULL) { size_t len = strlen(line); while ((len > 0) && ((line[len-1] == '\r') || (line[len-1] == '\n') || (line[len-1] == ' '))) { line[len-1] = '\0'; len--; } if (len > 0) new_recipe_name(recipe_no, line); recipe_no++; } fclose(fp); }
/* * This function builds probability tables from a list of purely alphabetical * lower-case words, and puts them into the supplied name_probs object. * The array of names should have a NULL entry at the end of the list. * It relies on the ASCII character set (through use of A2I). */ static void build_prob(name_probs probs, cptr *learn) { int c_prev, c_cur, c_next; cptr ch; int i; /* Build raw frequencies */ for (i = 0; learn[i] != NULL; i++) { c_prev = c_cur = S_WORD; ch = learn[i]; /* Iterate over the next word */ while (*ch != '\0') { c_next = A2I(my_tolower((unsigned char)*ch)); probs[c_prev][c_cur][c_next]++; probs[c_prev][c_cur][TOTAL]++; /* Step on */ c_prev = c_cur; c_cur = c_next; ch++; } probs[c_prev][c_cur][E_WORD]++; probs[c_prev][c_cur][TOTAL]++; } }
void load_entrable_list() { FILE *f = NULL; char strLine[255]; int off; memset(entrable_objects, 0, sizeof(entrable_objects)); nr_entrable_objects = 0; f=open_file_data("entrable.lst", "rb"); if(f == NULL) { LOG_ERROR("%s: %s \"entrable.lst\": %s\n", reg_error_str, cant_open_file, strerror(errno)); return; } while (nr_entrable_objects < MAX_ENTRABLE_OBJECTS) { if (fscanf(f, "%254s", strLine) != 1) break; my_tolower(strLine); off = *strLine == '/' ? 1 : 0; my_strncp(entrable_objects[nr_entrable_objects], strLine+off, OBJ_NAME_SIZE); nr_entrable_objects++; if (!fgets(strLine, sizeof(strLine), f)) break; } fclose(f); // Sort the list so we can use binary search qsort(entrable_objects, nr_entrable_objects, OBJ_NAME_SIZE, (int(*)(const void*,const void*))strcmp); }
void save_server_markings(){ char fname[128]; FILE *fp; server_mark *sm; hash_entry *he; if(!server_marks) return; //open server markings file safe_snprintf(fname, sizeof(fname), "servermarks_%s.dat",username_str); my_tolower(fname); fp = open_file_config(fname,"w"); if(fp == NULL){ LOG_ERROR("%s: %s \"%s\": %s\n", reg_error_str, cant_open_file, fname, strerror(errno)); return; } hash_start_iterator(server_marks); while((he=hash_get_next(server_marks))){ sm = (server_mark *) he->item; fprintf(fp,"%d %d %d %s %s\n",sm->id, sm->x, sm->y, sm->map_name, sm->text); } fclose (fp); LOG_DEBUG("Wrote server markings to file '%s'", fname); }
void send_input_text_line (char *line, int line_len) { char str[256]; int i,j; int len; Uint8 ch; switch(use_windowed_chat) { case 1: if(tabs[current_tab].channel != CHAT_ALL) { change_to_current_tab(line); } break; case 2: if(channels[active_tab].chan_nr != CHAT_ALL) { change_to_current_chat_tab(line); } break; } if ( caps_filter && line_len > 4 && my_isupper (line, -1) ) my_tolower (line); i=0; j=1; if (line[0] != '/' && line[0] != char_slash_str[0]) //we don't have a PM { str[0] = RAW_TEXT; } else { str[0] = SEND_PM; i++; // skip the leading / } for ( ; i < line_len && j < sizeof (str) - 1; i++) // copy it, but ignore the enter { ch = line[i]; if (ch != '\n' && ch != '\r') { str[j] = ch; j++; } } str[j] = 0; // always a NULL at the end len = strlen (&str[1]); if (my_tcp_send (my_socket, (Uint8*)str, len+1) < len+1) { //we got a nasty error, log it } return; }
static char *str2lower(char *str) { char *res; int size; int i; size = my_strlen(str); res = xmalloc(size + 1); for (i = 0; i < size; i++) res[i] = my_tolower(str[i]); res[size] = 0; return res; }
static unsigned long my_atou_x(char *s) { unsigned radix=10, c; unsigned long n=0; while (*s == ' ' || *s == '\t') s++; if (s[0] == '0' && s[1] == 'x') { radix = 16; s += 2; } while (my_isalnum(*s)) { c = my_tolower(*s); s++; if (my_isdigit(c)) c=c-'0'; else c=c-'A'+10; if (c >= radix) break; n = n * radix + c; } return n; }
void save_recipes(){ char fname[128]; FILE *fp; if (!recipes_loaded) return; save_recipe_names(); safe_snprintf(fname, sizeof(fname), "recipes_%s.dat",username_str); my_tolower(fname); fp=open_file_config(fname,"wb"); if(fp == NULL){ LOG_ERROR("%s: %s \"%s\"\n", reg_error_str, cant_open_file, fname); return; } fwrite(recipes, sizeof(recipes), 1, fp); fclose(fp); }
/* save recipe names to file if any have changed */ static void save_recipe_names(void) { char fname[128]; FILE *fp; size_t i; int errorflag = 0; if (!recipe_names_changed) return; safe_snprintf(fname, sizeof(fname), "recipes_%s.names",username_str); my_tolower(fname); fp = open_file_config(fname,"w"); if(fp == NULL) { LOG_ERROR("%s() %s \"%s\" [%s]\n", __FUNCTION__, cant_open_file, fname, strerror(errno)); return; } for (i=0; i<SHOW_MAX_RECIPE; i++) { if (recipe_name[i] != NULL) { if (fputs(recipe_name[i], fp) < 0) { errorflag = 1; break; } } if (fputc('\n', fp) != '\n') { errorflag = 1; break; } } if (errorflag) LOG_ERROR("%s() %s \"%s\" [%s]\n", __FUNCTION__, cant_open_file, fname, strerror(errno)); fclose(fp); }
/**************************************************************************** Initialize events. Now also initialise sorted_events[]. ****************************************************************************/ void events_init(void) { int i; for (i = 0; i < ARRAY_SIZE(event_to_index); i++) { event_to_index[i] = 0; } for (i = 0; events[i].enum_name; i++) { int j; if (E_S_XYZZY > events[i].esn) { const char *event_format = Q_(event_sections[events[i].esn]); int l = 1 + strlen(event_format) + strlen(_(events[i].descr_orig)); events[i].full_descr = fc_malloc(l); my_snprintf(events[i].full_descr, l, event_format, _(events[i].descr_orig)); } else { /* No section part */ events[i].full_descr = _(events[i].descr_orig); } event_to_index[events[i].event] = i; events[i].tag_name = mystrdup(events[i].enum_name); for (j = 0; j < strlen(events[i].tag_name); j++) { events[i].tag_name[j] = my_tolower(events[i].tag_name[j]); } freelog(LOG_DEBUG, "event[%d]=%d: name='%s' / '%s'\n\tdescr_orig='%s'\n\tdescr='%s'", i, events[i].event, events[i].enum_name, events[i].tag_name, events[i].descr_orig, events[i].full_descr); } for (i = 0; i < E_LAST; i++) { sorted_events[i] = i; } qsort(sorted_events, E_LAST, sizeof(*sorted_events), compar_event_message_texts); }
void send_login_info() { int i; int j; int len; unsigned char str[40]; len=strlen(username_str); //check for the username lenght if(len<3) { sprintf(log_in_error_str,"%s: %s",reg_error_str,error_username_length); return; } //join the username and password, and send them to the server str[0]=LOG_IN; if(caps_filter && my_isupper(username_str, len)) my_tolower(username_str); for(i=0;i<len;i++)str[i+1]=username_str[i]; str[i+1]=' '; i++; len=strlen(password_str); for(j=0;j<len;j++)str[i+j+1]=password_str[j]; str[i+j+1]=0; //are we going to use this? //clear the password field, in order not to try to relogin again //password_str[0]=0; //display_password_str[0]=0; //password_text_lenght=0; len=strlen(str); len++;//send the last 0 too if(my_tcp_send(my_socket,str,len)<len) { //we got a nasty error, log it } }
void send_input_text_line() { char str[256]; int i,j; int len; Uint8 ch; if(caps_filter && strlen(input_text_line) > 4 && my_isupper(input_text_line, -1)) my_tolower(input_text_line); i=0; j=1; if(input_text_line[0]!='/')//we don't have a PM { str[0]=RAW_TEXT; } else { str[0]=SEND_PM; i++; // skip the leading / } for(;i<input_text_lenght;i++) // copy it, but ignore the enter { ch=input_text_line[i]; if(ch!=0x0a) { str[j]=ch; j++; } } str[j]=0; // always a NULL at the end len=strlen(&str[1]); if(my_tcp_send(my_socket,str,len+1)<len+1) { //we got a nasty error, log it } return; }
/* load recipes, done just after login when we have the player name */ void load_recipes (){ char fname[128]; FILE *fp; size_t i; int logged = 0; off_t file_size; const size_t recipe_size = sizeof(item)*NUM_MIX_SLOTS; if (recipes_loaded) { /* * save existing recipes instead of loading them if we are already logged in * this will take place when relogging after disconnection */ save_recipes(); save_recipe_names(); return; } safe_snprintf(fname, sizeof(fname), "recipes_%s.dat",username_str); my_tolower(fname); /* get file length, if a valid length adjust the number of recipe slots if required */ file_size = get_file_size_config(fname); if ((file_size > 0) && (file_size % recipe_size == 0)) { int num_recipes_in_file = file_size / recipe_size - 1; // -1 as last is current in pipline if ((num_recipes_in_file > wanted_num_recipe_entries) && (num_recipes_in_file < max_num_recipe_entries)) { wanted_num_recipe_entries = num_recipes_in_file; set_var_OPT_INT("wanted_num_recipe_entries", wanted_num_recipe_entries); } } /* allocate and initialise the recipe store */ num_recipe_entries = max_prev_num_recipe_entries = wanted_num_recipe_entries; recipes_store = (recipe_entry *)calloc(num_recipe_entries, sizeof(recipe_entry)); if (recipes_store == NULL) { max_prev_num_recipe_entries = num_recipe_entries = 0; return; } recipes_loaded=1; init_recipe_names(); /* if the file exists but is not a valid size, don't use it */ if ((file_size > 0) && (file_size % recipe_size != 0)) { LOG_ERROR("%s: Invalid format (size mismatch) \"%s\"\n", reg_error_str, fname); return; } /* sliently ignore non existing file */ if (!file_exists_config(fname)) return; fp = open_file_config(fname,"rb"); if(fp == NULL){ LOG_ERROR("%s: %s \"%s\": %s\n", reg_error_str, cant_open_file, fname, strerror(errno)); return; } /* attempt to read all the recipies we're expecting */ for (i=0; !feof(fp) && i<num_recipe_entries; i++) { if (fread (recipes_store[i].items,recipe_size,1, fp) != 1) { if (!logged) { LOG_ERROR("%s() fail during read of file [%s] : %s\n", __FUNCTION__, fname, strerror(errno)); logged = 1; } memset(recipes_store[i].items, 0, recipe_size); break; } } /* if there is another, use it as the current recipe in the manufacturing pipeline */ if (!feof(fp)) if (fread (manu_recipe.items,recipe_size,1, fp) != 1) memset(manu_recipe.items, 0, recipe_size); fclose (fp); load_recipe_names(); }
void extract_feats(vector<string> &W,vector<string>& P,vector<vector<string> >& O,bool lowercase, vector<string>& LOW){ int n = W.size(), m = P.size(); vector<string> SH, SB, SB3, PR, PR3; for (int i = 0; i < n; ++i){ string w = W[i], pos = ""; if (lowercase) w = my_tolower(W[i]); if (m > 0) pos = P[i]; string sh = "", lemma = "", sb = "", sb3="", pr = "", pr3 = ""; lemma = my_tolower_sh(w,sh); if (lemma.size() > 2){ sb = string(lemma,lemma.size()-2,2); pr = string(lemma,0,2); } if (lemma.size() > 3){ sb3 = string(lemma,lemma.size()-3,3); pr3 = string(lemma,0,3); } if (pos != "") P.push_back(pos); SB.push_back(sb); SB3.push_back(sb3); PR.push_back(pr); PR3.push_back(pr3); LOW.push_back(lemma); SH.push_back(sh); } for (int i = 0; i < W.size(); ++i){ vector<string> W_i; #if USE_KF W_i.push_back("KF"); #endif #if USE_RELPOS_FEATS if (i==0) W_i.push_back("rp=begin"); else if (i<W.size()-1) W_i.push_back("rp=mid"); else W_i.push_back("rp=end"); #endif if (i > 0){ if (m) W_i.push_back("pos-1="+P[i-1]); #if USE_WORDS W_i.push_back("w-1="+LOW[i-1]); #endif W_i.push_back("sh-1="+SH[i-1]); W_i.push_back("sb-1="+SB[i-1]); } if (i < W.size()-1){ if (m) W_i.push_back("pos+1="+P[i+1]); #if USE_WORDS W_i.push_back("w+1="+LOW[i+1]); #endif W_i.push_back("sh+1="+SH[i+1]); W_i.push_back("sb+1="+SB[i+1]); } #if USE_WORDS W_i.push_back("w="+LOW[i]); #endif if (m) W_i.push_back("pos="+P[i]); W_i.push_back("sh="+SH[i]); W_i.push_back("pr="+PR[i]); W_i.push_back("pr3="+PR3[i]); W_i.push_back("sb="+SB[i]); W_i.push_back("sb3="+SB3[i]); O.push_back(W_i); } }
void add_enhanced_actor_from_server(char * in_data) { short actor_id; short x_pos; short y_pos; short z_pos; short z_rot; short max_health; short cur_health; Uint8 actor_type; Uint8 skin; Uint8 hair; Uint8 shirt; Uint8 pants; Uint8 boots; Uint8 frame; Uint8 cape; Uint8 head; Uint8 shield; Uint8 weapon; Uint8 helmet; int i; int dead=0; int kind_of_actor; enhanced_actor *this_actor; char cur_frame[20]; double f_x_pos,f_y_pos,f_z_pos,f_z_rot; actor_id=*((short *)(in_data)); x_pos=*((short *)(in_data+2)); y_pos=*((short *)(in_data+4)); z_pos=*((short *)(in_data+6)); z_rot=*((short *)(in_data+8)); actor_type=*(in_data+10); skin=*(in_data+12); hair=*(in_data+13); shirt=*(in_data+14); pants=*(in_data+15); boots=*(in_data+16); head=*(in_data+17); shield=*(in_data+18); weapon=*(in_data+19); cape=*(in_data+20); helmet=*(in_data+21); frame=*(in_data+22); max_health=*((short *)(in_data+23)); cur_health=*((short *)(in_data+25)); kind_of_actor=*(in_data+27); //translate from tile to world f_x_pos=x_pos*0.5; f_y_pos=y_pos*0.5; f_z_pos=z_pos; f_z_rot=z_rot; //get the current frame switch(frame) { case frame_walk: my_strcp(cur_frame,actors_defs[actor_type].walk_frame);break; case frame_run: my_strcp(cur_frame,actors_defs[actor_type].run_frame);break; case frame_die1: my_strcp(cur_frame,actors_defs[actor_type].die1_frame); dead=1; break; case frame_die2: my_strcp(cur_frame,actors_defs[actor_type].die2_frame); dead=1; break; case frame_pain1: my_strcp(cur_frame,actors_defs[actor_type].pain1_frame);break; case frame_pain2: my_strcp(cur_frame,actors_defs[actor_type].pain2_frame);break; case frame_pick: my_strcp(cur_frame,actors_defs[actor_type].pick_frame);break; case frame_drop: my_strcp(cur_frame,actors_defs[actor_type].drop_frame);break; case frame_idle: my_strcp(cur_frame,actors_defs[actor_type].idle_frame);break; case frame_sit_idle: my_strcp(cur_frame,actors_defs[actor_type].idle_sit_frame);break; case frame_harvest: my_strcp(cur_frame,actors_defs[actor_type].harvest_frame);break; case frame_cast: my_strcp(cur_frame,actors_defs[actor_type].attack_cast_frame);break; case frame_attack_up_1: my_strcp(cur_frame,actors_defs[actor_type].attack_up_1_frame);break; case frame_attack_up_2: my_strcp(cur_frame,actors_defs[actor_type].attack_up_2_frame);break; case frame_attack_up_3: my_strcp(cur_frame,actors_defs[actor_type].attack_up_3_frame);break; case frame_attack_up_4: my_strcp(cur_frame,actors_defs[actor_type].attack_up_4_frame);break; case frame_attack_down_1: my_strcp(cur_frame,actors_defs[actor_type].attack_down_1_frame);break; case frame_attack_down_2: my_strcp(cur_frame,actors_defs[actor_type].attack_down_2_frame);break; case frame_combat_idle: my_strcp(cur_frame,actors_defs[actor_type].combat_idle_frame);break; default: { } } //find out if there is another actor with that ID //ideally this shouldn't happen, but just in case for(i=0;i<max_actors;i++) { if(actors_list[i]) { if(actors_list[i]->actor_id==actor_id) { char str[256]; sprintf(str,"%s %d = %s => %s\n",duplicate_actors_str,actor_id, actors_list[i]->actor_name ,&in_data[28]); log_error(str); destroy_actor(actors_list[i]->actor_id);//we don't want two actors with the same ID i--;// last actor was put here, he needs to be checked too } else if(kind_of_actor==COMPUTER_CONTROLLED_HUMAN && (actors_list[i]->kind_of_actor==COMPUTER_CONTROLLED_HUMAN || actors_list[i]->kind_of_actor==PKABLE_COMPUTER_CONTROLLED) && !my_strcompare(&in_data[28], actors_list[i]->actor_name)) { char str[256]; sprintf(str,"%s(%d) = %s => %s\n",duplicate_npc_actor,actor_id, actors_list[i]->actor_name ,&in_data[28]); log_error(str); destroy_actor(actors_list[i]->actor_id);//we don't want two actors with the same ID i--;// last actor was put here, he needs to be checked too } } } this_actor=calloc(1,sizeof(enhanced_actor)); //get the torso my_strcp(this_actor->arms_tex,actors_defs[actor_type].shirt[shirt].arms_name); my_strcp(this_actor->torso_tex,actors_defs[actor_type].shirt[shirt].torso_name); my_strcp(this_actor->torso_fn,actors_defs[actor_type].shirt[shirt].model_name); //skin my_strcp(this_actor->hands_tex,actors_defs[actor_type].skin[skin].hands_name); my_strcp(this_actor->hands_tex_save,actors_defs[actor_type].skin[skin].hands_name); my_strcp(this_actor->head_tex,actors_defs[actor_type].skin[skin].head_name); //hair my_strcp(this_actor->hair_tex,actors_defs[actor_type].hair[hair].hair_name); //boots my_strcp(this_actor->boots_tex,actors_defs[actor_type].boots[boots].boots_name); //legs my_strcp(this_actor->pants_tex,actors_defs[actor_type].legs[pants].legs_name); my_strcp(this_actor->legs_fn,actors_defs[actor_type].legs[pants].model_name); //cape if(cape!=CAPE_NONE) { my_strcp(this_actor->cape_tex,actors_defs[actor_type].cape[cape].skin_name); my_strcp(this_actor->cape_fn,actors_defs[actor_type].cape[cape].model_name); } else { my_strcp(this_actor->cape_tex,""); my_strcp(this_actor->cape_fn,""); } //head my_strcp(this_actor->head_fn,actors_defs[actor_type].head[head].model_name); //shield if(shield!=SHIELD_NONE) { my_strcp(this_actor->shield_tex,actors_defs[actor_type].shield[shield].skin_name); my_strcp(this_actor->shield_fn,actors_defs[actor_type].shield[shield].model_name); } else { my_strcp(this_actor->shield_tex,""); my_strcp(this_actor->shield_fn,""); } my_strcp(this_actor->weapon_tex,actors_defs[actor_type].weapon[weapon].skin_name); my_strcp(this_actor->weapon_fn,actors_defs[actor_type].weapon[weapon].model_name); this_actor->weapon_glow=actors_defs[actor_type].weapon[weapon].glow; if(weapon == GLOVE_FUR || weapon == GLOVE_LEATHER){ my_strcp(this_actor->hands_tex, actors_defs[actor_type].weapon[weapon].skin_name); } //helmet if(helmet!=HELMET_NONE) { my_strcp(this_actor->helmet_tex,actors_defs[actor_type].helmet[helmet].skin_name); my_strcp(this_actor->helmet_fn,actors_defs[actor_type].helmet[helmet].model_name); } else { my_strcp(this_actor->helmet_tex,""); my_strcp(this_actor->helmet_fn,""); } i=add_enhanced_actor(this_actor,cur_frame,f_x_pos,f_y_pos,f_z_pos,f_z_rot,actor_id); actors_list[i]->x_tile_pos=x_pos; actors_list[i]->y_tile_pos=y_pos; actors_list[i]->actor_type=actor_type; actors_list[i]->damage=0; actors_list[i]->damage_ms=0; actors_list[i]->sitting=0; actors_list[i]->fighting=0; //test only actors_list[i]->max_health=max_health; actors_list[i]->cur_health=cur_health; if(frame==frame_sit_idle) { if(actors_list[i]->actor_id==yourself)you_sit_down(); actors_list[i]->sitting=1; } else if(frame==frame_combat_idle) actors_list[i]->fighting=1; //ghost or not? actors_list[i]->ghost=0; actors_list[i]->dead=dead; actors_list[i]->stop_animation=1;//helps when the actor is dead... actors_list[i]->cur_weapon=weapon; actors_list[i]->kind_of_actor=kind_of_actor; if(strlen(&in_data[28]) >= 30) { char str[120]; snprintf(str, 120, "%s (%d): %s/%d\n", bad_actor_name_length, actors_list[i]->actor_type,&in_data[28], (int)strlen(&in_data[28])); log_error(str); return; } my_strncp(actors_list[i]->actor_name,&in_data[28],30); if(caps_filter && my_isupper(actors_list[i]->actor_name, -1)) my_tolower(actors_list[i]->actor_name); unlock_actors_lists(); //unlock it }
char* dirname (char *path) { static const char here[] = "."; char* backslash; char* slash; char* last_slash; if (path == NULL) { return (char*) here; /* Yes, this is stupid. See below! */ } else if ((path[0] == 'U' || path[0] == 'u') && path[1] == ':' && path[2] == '\0' && __mint) { path[0] = '/'; path[1] = '\0'; return path; } else if (path[1] == ':' && path[2] == '\0' && ((path[0] >= 'A' && path[0] <= 'Z' && path[0] != 'U') || (path[0] >= 'a' && path[0] <= 'z') || (path[0] >= '0' && path[0] <= '9'))) { /* A drive letter followed by a colon. */ if (__mint) { path[1] = my_tolower (path[1]); path[0] = '/'; } return path; /* It IS null-terminated. */ } slash = strrchr (path, '/'); backslash = strrchr (path, '\\'); if (slash > backslash) last_slash = slash; else if (backslash != NULL) last_slash = backslash; else last_slash = NULL; /* End of Atari-specifific kludges. The rest is more or less taken unchanged from the GNU libc. */ if (last_slash == path) { /* The last slash is the first character in the string. We have to return "/". */ ++last_slash; } else if (last_slash != NULL && last_slash[1] == '\0') { /* The '/' or '\\' is the last character, we have to look further. */ char* maybe_last_slash = memchr (path, last_slash - path, '/'); if (maybe_last_slash == NULL) maybe_last_slash = memchr (path, last_slash - path, '\\'); last_slash = maybe_last_slash; } if (last_slash != NULL) /* Terminate the path. */ last_slash[0] = '\0'; else /* This assignment is ill-designed but the XPG specs require to return a string containing "." in any case no directory part is found and so a static and constant string is required. */ path = (char*) here; return path; }