Skip to content

Commit

Permalink
Moved card0 check to config & Flux lib
Browse files Browse the repository at this point in the history
* Fixed rathena#190
* The card0 values are defined in config file (application.php) in `ItemSpecial`. By default, using rAthena's card0 values.
* The usage will be `Flux::itemIsSpecial($item)`. Returns `true` if item's card0 is special, `false` otherwise
* For control checking (ifs) for item is forged
  * `if ($item->card0 == $this->itemIsForged)`
  * `if ($item->card0 == $this->itemIsCreation)`
  * `if ($item->card0 == $this->itemIsPetEgg)`
  • Loading branch information
cydh committed Jun 20, 2018
1 parent cb92485 commit 80e2bc4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@
array('module' => 'guild', 'action' => 'emblem')
),

// Card0 special flag. Older rAthena the values are 254,255,-256
'ItemSpecial' => array(
'forge' => 0x00FF,
'create' => 0x00FE,
'pet' => 0x0100,
),

// Job classes, loaded from another file to avoid cluttering this one.
// There isn't normally a need to modify this file, unless it's been
// modified in an update. (In English: DON'T TOUCH THIS.)
Expand Down
14 changes: 14 additions & 0 deletions lib/Flux.php
Original file line number Diff line number Diff line change
Expand Up @@ -934,5 +934,19 @@ public static function monsterSizeName($size)
$size = Flux::config("MonsterSizes.$size");
return $size;
}

/**
* Check if item is special
* @param $item Item object fetched from table
* @return True if item's card0 is special, false otherwise
*/
public static function itemIsSpecial($item) {
$special = Flux::config('ItemSpecial');
if (!$special)
return false;
if ($item->card0 && ($item->card0 == $special->get('forge') || $item->card0 == $special->get('create') || $item->card0 == $special->get('pet')))
return true;
return false;
}
}
?>
20 changes: 20 additions & 0 deletions lib/Flux/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ class Flux_Template {
protected $urlWithQs;
protected $urlWithQS; // compatibility.

/**
* CARD0_FORGE value for checking
*/
protected $itemIsForged;

/**
* CARD0_CREATE value for checking
*/
protected $itemIsCreation;

/**
* CARD0_PET value for checking
*/
protected $itemIsPetEgg;

/**
* Module/action for missing action's event.
*
Expand Down Expand Up @@ -228,6 +243,11 @@ public function __construct(Flux_Config $config)
$this->missingViewModuleAction = $config->get('missingViewModuleAction', false);
$this->referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';

$special = Flux::config('ItemSpecial');
$this->itemIsForged = $special->get('forge');
$this->itemIsCreation = $special->get('create');
$this->itemIsPetEgg = $special->get('pet');

// Read manifest file if exists
if (file_exists($this->themePath.'/'.$this->themeName.'/manifest.php')) {
$manifest = include($this->themePath.'/'.$this->themeName.'/manifest.php');
Expand Down

0 comments on commit 80e2bc4

Please sign in to comment.