I'm trying to write back to a block in memory (that I write to a file later with no problems) but for some reason after the 3rd loop it is not writing properly. It keeps adding on 101 in different offsets when it's not supposed to...I think...I don't know, at least it's not one of this programs intended functions. void parse_stats() does it's job and write_stats() should be formatting it the way parse stats reads...sorry bout the lack of comments. It's a diablo II v1.11 savegame editor I am working on as a hobby in linux or even windows if need be.

Code:void parse_stats(unsigned int offset) { unsigned long int temp_read, current_stat, current_value; unsigned long int *read[16] = {&d2s_stats.strength, &d2s_stats.energy, &d2s_stats.dexterity, &d2s_stats.vitality, &d2s_stats.stat_points, &d2s_stats.skill_points, &d2s_stats.current_hp, &d2s_stats.total_hp, &d2s_stats.current_mp, &d2s_stats.total_mp, &d2s_stats.current_sp, &d2s_stats.total_sp, &d2s_stats.level, &d2s_stats.experience, &d2s_stats.gold_in_belt, &d2s_stats.gold_in_stash}; unsigned int counter = 0; for (;;) { file.seekg((counter / 8) + offset, ios::beg); file.read((char*)&temp_read, 4); current_stat = temp_read >> (counter % 8) & 0x1FF; counter += current_stat_length[current_stat]; if(current_stat == 0x1FF) { file.seekg(-4, ios::cur); break; } file.seekg((counter / 8) + offset, ios::beg); file.read((char*)&temp_read, 4); current_value = temp_read >> (counter % 8) & stat_filter[current_stat]; *read[current_stat] = current_value; counter += stat_length[current_stat]; // cout << stat_name[current_stat] << current_value << endl; } } void write_stats(char* stat[55]) { unsigned long int temp_write, current_stat, current_value; unsigned long int *write[16] = {&d2s_stats.strength, &d2s_stats.energy, &d2s_stats.dexterity, &d2s_stats.vitality, &d2s_stats.stat_points, &d2s_stats.skill_points, &d2s_stats.current_hp, &d2s_stats.total_hp, &d2s_stats.current_mp, &d2s_stats.total_mp, &d2s_stats.current_sp, &d2s_stats.total_sp, &d2s_stats.level, &d2s_stats.experience, &d2s_stats.gold_in_belt, &d2s_stats.gold_in_stash}; unsigned int counter = 0; for (int i = 0;i < 16;i++) { stat[counter / 8] += (i << (counter % 8)) & (current_stat_length_filter[i] << (counter % 8)) ; counter += current_stat_length[i]; stat[counter / 8] += (*write[i] << (counter % 8)) & (stat_filter[i] << (counter % 8)); current_value = *write[i]; counter += stat_length[i]; cin.get(); cout << stat_name[i] << current_value << endl; } }