Don't guard col_set_str (COL_INFO/COL_PROTOCOL) with col_check
[obnox/wireshark/wip.git] / epan / dissectors / packet-quake3.c
index 4bfa93e88fd873f5cd19d669676bec968e7b6702..89c244196edbe6cea3b303d619775c20e2766bdf 100644 (file)
@@ -5,8 +5,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * Copied from packet-quake2.c
@@ -44,7 +44,7 @@
 #include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
-#include "prefs.h"
+#include <epan/prefs.h>
 #include <epan/addr_resolv.h>
 
 static int proto_quake3 = -1;
@@ -77,8 +77,8 @@ static dissector_handle_t data_handle;
 
 #define QUAKE3_SERVER_PORT 27960
 #define QUAKE3_MASTER_PORT 27950
-static unsigned int gbl_quake3_server_port=QUAKE3_SERVER_PORT;
-static unsigned int gbl_quake3_master_port=QUAKE3_MASTER_PORT;
+static guint gbl_quake3_server_port=QUAKE3_SERVER_PORT;
+static guint gbl_quake3_master_port=QUAKE3_MASTER_PORT;
 
 
 static const value_string names_direction[] = {
@@ -277,7 +277,7 @@ dissect_quake3_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_,
                        proto_item      *server_item = NULL;
                        proto_tree      *server_tree = NULL;
 
-                       tvb_memcpy(tvb, (guint8 *)&ip_addr, base + 1, 4);
+                       ip_addr = tvb_get_ipv4(tvb, base + 1);
                        udp_port = tvb_get_ntohs(tvb, base + 5);
 
                        /* It may be a good idea to create a conversation for
@@ -485,8 +485,7 @@ dissect_quake3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        direction = DIR_UNKNOWN;
 
-       if (check_col(pinfo->cinfo, COL_PROTOCOL))
-               col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE3");
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUAKE3");
 
        if (tree) {
                quake3_item = proto_tree_add_item(tree, proto_quake3,
@@ -506,9 +505,7 @@ dissect_quake3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        }
 
        if (tvb_get_ntohl(tvb, 0) == 0xffffffff) {
-               if (check_col(pinfo->cinfo, COL_INFO)) {
-                       col_set_str(pinfo->cinfo, COL_INFO, "Connectionless ");
-               }
+               col_set_str(pinfo->cinfo, COL_INFO, "Connectionless ");
                if (quake3_tree)
                        proto_tree_add_uint_format(quake3_tree,
                                hf_quake3_connectionless,
@@ -518,9 +515,7 @@ dissect_quake3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        tvb, pinfo, quake3_tree, &direction);
        }
        else {
-               if (check_col(pinfo->cinfo, COL_INFO)) {
-                       col_set_str(pinfo->cinfo, COL_INFO, "Game ");
-               }
+               col_set_str(pinfo->cinfo, COL_INFO, "Game ");
                if (quake3_tree)
                        proto_tree_add_uint_format(quake3_tree,
                                hf_quake3_game,
@@ -544,15 +539,16 @@ dissect_quake3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 void
 proto_reg_handoff_quake3(void)
 {
-       static int initialized=FALSE;
+       static gboolean initialized=FALSE;
        static dissector_handle_t quake3_handle;
-       static int server_port;
-       static int master_port;
+       static guint server_port;
+       static guint master_port;
        int i;
 
        if (!initialized) {
                quake3_handle = create_dissector_handle(dissect_quake3,
                                proto_quake3);
+               data_handle = find_dissector("data");
                initialized=TRUE;
        } else {
                for (i=0;i<4;i++)
@@ -572,7 +568,6 @@ proto_reg_handoff_quake3(void)
        for (i=0;i<4;i++)
                dissector_add("udp.port", gbl_quake3_master_port + i,
                        quake3_handle);
-       data_handle = find_dissector("data");
 }
 
 
@@ -582,31 +577,31 @@ proto_register_quake3(void)
        static hf_register_info hf[] = {
                { &hf_quake3_direction,
                        { "Direction", "quake3.direction",
-                       FT_NONE, BASE_DEC, NULL, 0x0,
+                       FT_NONE, BASE_NONE, NULL, 0x0,
                        "Packet Direction", HFILL }},
                { &hf_quake3_connectionless,
                        { "Connectionless", "quake3.connectionless",
                        FT_UINT32, BASE_DEC, NULL, 0x0,
-                       "Connectionless", HFILL }},
+                       NULL, HFILL }},
                { &hf_quake3_game,
                        { "Game", "quake3.game",
                        FT_UINT32, BASE_DEC, NULL, 0x0,
-                       "Game", HFILL }},
+                       NULL, HFILL }},
                { &hf_quake3_connectionless_marker,
                        { "Marker", "quake3.connectionless.marker",
                        FT_UINT32, BASE_HEX, NULL, 0x0,
-                       "Marker", HFILL }},
+                       NULL, HFILL }},
                { &hf_quake3_connectionless_text,
                        { "Text", "quake3.connectionless.text",
-                       FT_STRING, BASE_DEC, NULL, 0x0,
-                       "Text", HFILL }},
+                       FT_STRING, BASE_NONE, NULL, 0x0,
+                       NULL, HFILL }},
                { &hf_quake3_connectionless_command,
                        { "Command", "quake3.connectionless.command",
-                       FT_STRING, BASE_DEC, NULL, 0x0,
-                       "Command", HFILL }},
+                       FT_STRING, BASE_NONE, NULL, 0x0,
+                       NULL, HFILL }},
                { &hf_quake3_server_addr,
                        { "Server Address", "quake3.server.addr",
-                       FT_IPv4, BASE_DEC, NULL, 0x0,
+                       FT_IPv4, BASE_NONE, NULL, 0x0,
                        "Server IP Address", HFILL }},
                { &hf_quake3_server_port,
                        { "Server Port", "quake3.server.port",
@@ -618,7 +613,7 @@ proto_register_quake3(void)
                        "Sequence number of the current packet", HFILL }},
                { &hf_quake3_game_rel1,
                        { "Reliable", "quake3.game.rel1",
-                       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+                       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                        "Packet is reliable and may be retransmitted", HFILL }},
                { &hf_quake3_game_seq2,
                        { "Sequence Number", "quake3.game.seq2",
@@ -626,7 +621,7 @@ proto_register_quake3(void)
                        "Sequence number of the last received packet", HFILL }},
                { &hf_quake3_game_rel2,
                        { "Reliable", "quake3.game.rel2",
-                       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+                       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                        "Packet was reliable and may be retransmitted", HFILL }},
                { &hf_quake3_game_qport,
                        { "QPort", "quake3.game.qport",