| 308 | } |
| 309 | |
| 310 | BOOL pfile_ui_save_create(_uiheroinfo *heroinfo) |
| 311 | { |
| 312 | DWORD save_num; |
| 313 | char cl; |
| 314 | PkPlayerStruct pkplr; |
| 315 | |
| 316 | save_num = pfile_get_save_num_from_name(heroinfo->name); |
| 317 | if (save_num == MAX_CHARACTERS) { |
| 318 | for (save_num = 0; save_num < MAX_CHARACTERS; save_num++) { |
| 319 | if (!hero_names[save_num][0]) |
| 320 | break; |
| 321 | } |
| 322 | if (save_num == MAX_CHARACTERS) |
| 323 | return FALSE; |
| 324 | } |
| 325 | if (!pfile_open_archive(FALSE, save_num)) |
| 326 | return FALSE; |
| 327 | mpqapi_remove_hash_entries(pfile_get_file_name); |
| 328 | strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN); |
| 329 | hero_names[save_num][PLR_NAME_LEN - 1] = '\0'; |
| 330 | cl = pfile_get_player_class(heroinfo->heroclass); |
| 331 | CreatePlayer(0, cl); |
| 332 | strncpy(plr[0]._pName, heroinfo->name, PLR_NAME_LEN); |
| 333 | plr[0]._pName[PLR_NAME_LEN - 1] = '\0'; |
| 334 | PackPlayer(&pkplr, 0, TRUE); |
| 335 | pfile_encode_hero(&pkplr); |
| 336 | game_2_ui_player(&plr[0], heroinfo, FALSE); |
| 337 | pfile_flush(TRUE, save_num); |
| 338 | return TRUE; |
| 339 | } |
| 340 | |
| 341 | BOOL pfile_get_file_name(DWORD lvl, char *dst) |
| 342 | { |
nothing calls this directly
no test coverage detected