MCPcopy Create free account
hub / github.com/diasurgical/devilution / pfile_ui_save_create

Function pfile_ui_save_create

Source/pfile.cpp:310–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310BOOL 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
341BOOL pfile_get_file_name(DWORD lvl, char *dst)
342{

Callers

nothing calls this directly

Calls 9

pfile_open_archiveFunction · 0.85
pfile_get_player_classFunction · 0.85
CreatePlayerFunction · 0.85
PackPlayerFunction · 0.85
pfile_encode_heroFunction · 0.85
game_2_ui_playerFunction · 0.85
pfile_flushFunction · 0.85

Tested by

no test coverage detected