Skip to content

Commit

Permalink
NPCs no longer required to use 'zone * 1000' convention.
Browse files Browse the repository at this point in the history
Zones will now only show NPCs in a spawnentry for that zone. Use the search bar for NPCs not in a spawnentry in order to edit.
  • Loading branch information
joligario committed Jan 6, 2019
1 parent 8f3b8ce commit 3e7c9b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$current_revision = "2 January 2019";
$current_revision = "5 January 2019";

require_once("config.php");
require_once("lib/logging.php");
Expand Down
22 changes: 19 additions & 3 deletions lib/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ function getZoneID($short_name) {

$query = "SELECT zoneidnumber AS id FROM zone WHERE short_name=\"$short_name\"";
$result = $mysql->query_assoc($query);
return $result['id'];
if ($result) {
return $result['id'];
}
else {
return null;
}
}

function getZoneIDByName($short_name) {
Expand Down Expand Up @@ -184,7 +189,12 @@ function get_zone_by_npcid($npcid) {
$query = "SELECT short_name FROM zone WHERE zoneidnumber=\"$npczone\"";
$result = $mysql->query_assoc($query);

return $result['short_name'];
if ($result) {
return $result['short_name'];
}
else {
return null;
}
}

function get_zoneid_by_npcid($npcid) {
Expand All @@ -193,7 +203,13 @@ function get_zoneid_by_npcid($npcid) {

$query = "SELECT id FROM zone WHERE zoneidnumber=\"$npczone\"";
$result = $mysql->query_assoc($query);
return $result['id'];

if ($result) {
return $result['id'];
}
else {
return null;
}
}

function get_npcid_by_emoteid($emoteid) {
Expand Down
6 changes: 4 additions & 2 deletions lib/headbars.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,13 @@ function npcs() {
$version = 0;
$zid = "___";
$results = array();
$zonename = "";

if($npc_list == '')
$npc_list = 1;

if($z) {
$zonename = $z;
$zid = getZoneID($z) . "___";
$query = "SELECT version FROM zone WHERE id = \"$zoneid\"";
$result = $mysql->query_assoc($query);
Expand All @@ -402,11 +404,11 @@ function npcs() {

if($npc_list == 1) {
if ($version > 0) {
$query = "SELECT id, name FROM npc_types WHERE id like \"$zid\" AND version = $version GROUP BY id ORDER BY name ASC";
$query = "SELECT npc_types.id AS id, npc_types.name AS name FROM npc_types JOIN spawnentry ON id = spawnentry.npcID JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID WHERE spawn2.zone = '$zonename' AND spawn2.version = $version GROUP BY id ORDER BY name ASC";
$results = $mysql->query_mult_assoc($query);
}
if ($version < 1) {
$query = "SELECT id, name FROM npc_types WHERE id like \"$zid\" GROUP BY id ORDER BY name ASC";
$query = "SELECT npc_types.id AS id, npc_types.name AS name FROM npc_types JOIN spawnentry ON id = spawnentry.npcID JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID WHERE spawn2.zone = '$zonename' AND spawn2.version = 0 ORDER BY name ASC";
$results = $mysql->query_mult_assoc($query);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,10 @@ function npc_info() {
function get_ispet() {
global $mysql, $npcid;

$query = "SELECT count(*) FROM pets WHERE npcID=$npcid";
$query = "SELECT count(*) AS count FROM pets WHERE npcID=$npcid";
$result = $mysql->query_assoc($query);

return $result['count(*)'];
return $result['count'];
}

function get_pet() {
Expand Down

1 comment on commit 3e7c9b4

@joligario
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #10

Please sign in to comment.