DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ OnStoreLoad()

bool OnStoreLoad ( ParamsReadContext ctx,
int version )
protected

См. определение в файле PlayerStomach.c строка 471

472 {
473 int checksum, count;
474 if (!ctx.Read(checksum))
475 {
476 return false;
477 }
478
479 if (!ctx.Read(count))
480 {
481 return false;
482 }
483 for (int i = 0; i < count; ++i)
484 {
485 int value, agents, temperature;
486 if (!ctx.Read(value))
487 return false;
488
489 if (!ctx.Read(agents))
490 return false;
491
492 if (version >= 140 && !ctx.Read(temperature))
493 return false;
494
495 if (checksum == CHECKSUM)//if checksum matches, add to stomach, otherwise throw the data away but go through the de-serialization to keep the stream intact
496 {
497 int amount = value >> quantity_bit_offset;//isolate amount bits
498 int id_mask = Math.Pow(2, quantity_bit_offset) - 1;
499 int id = (id_mask & value) >> id_bit_offset;//isolate id bits
500 int food_mask = Math.Pow(2, id_bit_offset) - 1;
501 int food_stage = value & food_mask;
502 //Print("LOAD value:" + value);
503 //Print("LOAD id:" + id);
504 //Print("LOAD id_bit_offset:" + id_bit_offset);
505 //Print("LOAD food_stage:" + food_stage);
506 string classname = GetClassnameFromID(id);
507 AddToStomach(classname, amount, food_stage, agents, temperature);
508 }
509 }
510 //Print("LOAD checksum:" + checksum);
511 if (checksum != CHECKSUM)
512 {
513 Print("Stomach checksum fail");
514 }
515 return true;
516 }
void AddToStomach(string class_name, float amount, int food_stage=0, int agents=0, float temperature=0)
Определения PlayerStomach.c:401
static int CHECKSUM
Определения PlayerStomach.c:125
const int quantity_bit_offset
Определения PlayerStomach.c:123
static string GetClassnameFromID(int id)
Определения PlayerStomach.c:197
const int id_bit_offset
Определения PlayerStomach.c:124
Определения EnMath.c:7
proto bool Read(void value_in)
proto void Print(void var)
Prints content of variable to console/log.
static proto float Pow(float v, float power)
Return power of v ^ power.

Перекрестные ссылки AddToStomach(), CHECKSUM, GetClassnameFromID(), id_bit_offset, Math::Pow(), Print(), quantity_bit_offset и Serializer::Read().