/** * */ public function getData($log_id, $lower, $upper) { //Return data if it is already loaded. if ($this->data != null) { return $this->data; } //Initialize stuff. $data =& $this->data; $parser =& $this->parser; $graph_data =& $this->graphdata; $players =& $this->players; //Variables needed for graph stuff. $elapsed = 0; //Loop through the contents and prepare data. $players = array(); $parser = new LogParser($log_id, $lower, $upper, $this->db); $data = new stdClass(); $data->maximum = array('dmg' => 0, 'heal' => 0, 'taken' => 0); $data->markings = array(); //Fetch encounter data from database. $rs = $this->db->where('id_log', $parser->log_id)->where('`start` <=', $lower)->where('`end` >=', $upper)->get('attempts'); $row = $rs->row(); $rs->free_result(); $data->encounter_boss = $this->boss_list[$row->id_boss - 1]->EN; $data->wipe = $row->wipe; //Buffers for markings. $raid_buffer = array(); $life_buffer = array(); while ($status = $parser->parseLine()) { //Skip misread lines. if ($status != LogParser::SUCCESS) { continue; } //Timestamp! $timestamp = $parser->getSeconds(); //Set the initial value for the timer if it hasn't started. if (!isset($data->l)) { $data->l = $timestamp; $data->timestamp = $timestamp; } //Ignore NPCs but see if we have detected which one it is. $is_npc = $parser->isNPC(); $is_pet = $parser->isPet(); //Ignore energy/mana gains or abilities we want filtered out. if ($parser->type_id == 27 || in_array($parser->attack_id, $this->global_filter)) { continue; } //Set initial values. $id = $is_pet ? $parser->pet_owner_id : ($is_npc ? $parser->target_id : $parser->origin_id); //Determine where we want to store the abilities. $loc = false; switch ($parser->type_id) { case 3: case 4: case 23: $loc = $is_npc ? $parser->target_type == 'P' ? 'dmg' : false : 'dmg'; break; //Damage //Damage case 5: case 28: //Healing $loc = false; switch (true) { case in_array($parser->attack_id, array(646325348, 759111971, 1256404592, 1297021479)): $life_buffer[] = array('type' => 1, 'time' => $timestamp - $data->l, 'length' => 0, 'actor' => $parser->target_name, 'origin' => $parser->origin_name, 'color' => '#0B0'); case !in_array($parser->attack_id, $this->heal_filter): if (!$is_npc) { $loc = 'heal'; } break; } break; case 6: case 7: //Attemting to capture bloodlust mechanics. //Capture only stuff that is cast on themself. $loc = false; if ($parser->origin_id != $parser->target_id || !in_array($parser->attack_id, array(766317719, 1742325987, 1559448016))) { break; } //If this was when the buff was cast... if ($parser->type_id == 6) { $raid_buffer[$parser->origin_id] = array('type' => 2, 'time' => $timestamp - $data->l, 'length' => 0, 'actor' => $parser->origin_name, 'origin' => $parser->attack_name); //Assign a color for the 3 different raid cooldowns. $color =& $raid_buffer[$parser->origin_id]['color']; switch ($parser->attack_id) { case 766317719: $color = '#004'; break; case 1742325987: $color = '#005'; break; case 1559448016: $color = '#006'; break; } } else { $buffer =& $raid_buffer[$parser->origin_id]; $buffer['length'] = $timestamp - $data->l - $buffer['time']; $data->markings[] = $buffer; } break; case 11: //Dying squirtle if ($is_npc && $parser->target_type == 'P') { $life_buffer[] = array('type' => 0, 'time' => $timestamp - $data->l, 'length' => 0, 'actor' => $parser->target_name, 'origin' => $parser->origin_name, 'color' => '#B00'); } break; default: $loc = false; break; } //Filter out stuff we don't care about. if (!$loc) { continue; } //Also filter out stuff that does zero damage. if ($parser->damage == 0 && $parser->absorbed == 0) { continue; } //Filtering complete, get the grand total for what we want. $total = $is_npc ? $parser->damage : $parser->damage + $parser->absorbed; //Now that we've filtered out the crap make sure this person exists. if (!isset($data->breakdown[$id])) { $data->breakdown[$id] = array('dmg' => array(), 'heal' => array(), 'taken' => array(), 'totals' => array('dmg' => 0, 'heal' => 0, 'taken' => 0), 'activity' => array('dmg' => array('total' => 0, 'last' => $timestamp, 'start' => $timestamp), 'heal' => array('total' => 0, 'last' => $timestamp, 'start' => $timestamp), 'taken' => array('total' => 0, 'last' => $timestamp, 'start' => $timestamp))); } //Make sure the name is set as well. if (!$is_pet && !isset($data->breakdown[$id]['name'])) { $data->breakdown[$id]['name'] = !$is_npc ? $parser->origin_name : $parser->target_name; } //Store the ability cast. if ($is_pet) { if (!isset($data->breakdown[$id]['pet'])) { $data->breakdown[$id]['pet'] = array('name' => $parser->origin_name, 'totals' => array('dmg' => 0, 'heal' => 0)); } $this->addValue($data->breakdown[$id]['pet'][$loc][$parser->attack_name], $total); $this->addValue($data->breakdown[$id]['pet']['totals'][$loc], $total); } else { //Filter and fix unwanted results. if ($is_npc && $loc == 'dmg') { $loc = 'taken'; } elseif ($is_npc) { continue; } //Finally output them. $this->addValue($data->breakdown[$id][$loc][$parser->attack_name], $total); } //Add it to the player total. $data->breakdown[$id]['totals'][$loc] += $total; //Add it to the graph data. $this->addValue($graph_data[$elapsed][$loc][$id], $total); //Maximum dmg/heal by user. if ($data->maximum[$loc] < $data->breakdown[$id]['totals'][$loc]) { $data->maximum[$loc] = $data->breakdown[$id]['totals'][$loc]; } //Add the ability to the grand total. $this->addValue($data->total[$loc], $total); //Update actor's activity. $data->breakdown[$id]['activity'][$loc]['last'] = $timestamp; //Calculate stuff every second. if ($timestamp - $data->timestamp >= 1) { //Activity. foreach ($data->breakdown as &$actor) { foreach ($actor['activity'] as $type => &$arr) { if ($timestamp - $arr['last'] <= 3 && $arr['start'] != $arr['last']) { $arr['total']++; } } } //Put zeroes in empty graph data slots. foreach ($graph_data[$elapsed] as $type => &$ids) { foreach ($data->breakdown as $id => &$arr) { if (!isset($ids[$id])) { $ids[$id] = 0; } } } //Update the elapsed timer for graph data. $elapsed += $timestamp - $data->timestamp; //Reset the timestamp. $data->timestamp = $timestamp; } } //Push deaths/revives to the markings array. foreach ($life_buffer as &$mark) { $data->markings[] = $mark; } //Calculate the final length. $data->l = $parser->getSeconds() - $data->l; $this->parseGraphData($graph_data); return $data; }