summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-08-27 13:40:22 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-08-27 13:40:38 -0700
commita88ffd2d9b2adec5de19a1bb88e6b8656985a044 (patch)
treec7c850ec7ccb0bc6e946588c72710092bbc0e163
parent99c9ab6b3c6b0a877b454346addd57d18d1ea07e (diff)
downloadtmwa-a88ffd2d9b2adec5de19a1bb88e6b8656985a044.tar.gz
tmwa-a88ffd2d9b2adec5de19a1bb88e6b8656985a044.tar.bz2
tmwa-a88ffd2d9b2adec5de19a1bb88e6b8656985a044.tar.xz
tmwa-a88ffd2d9b2adec5de19a1bb88e6b8656985a044.zip
Yes, I do
-rw-r--r--Makefile.in2
-rw-r--r--src/map/script.cpp24
-rwxr-xr-xtools/debug-debug-scripts28
3 files changed, 47 insertions, 7 deletions
diff --git a/Makefile.in b/Makefile.in
index a2cb67b..ee7a15d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -360,6 +360,8 @@ o: ${PDC_OBJECTS}
# duplicates, and PDC is more common, and also some override rules are only
# currently defined for PDC
+clean-stamp:
+ -$l find obj -name '*.stamp' -delete
clean-deps:
-$l find obj -name '*.d' -delete
clean-format:
diff --git a/src/map/script.cpp b/src/map/script.cpp
index d5eb379..4aeb7d9 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -1195,15 +1195,29 @@ RString conv_str(ScriptState *st, struct script_data *data)
static __attribute__((warn_unused_result))
int conv_num(ScriptState *st, struct script_data *data)
{
+ int rv = 0;
get_val(st, data);
assert (!data->is<ScriptDataRetInfo>());
- if (auto *u = data->get_if<ScriptDataStr>())
+ MATCH (*data)
{
- RString p = u->str;
- *data = ScriptDataInt{atoi(p.c_str())};
+ default:
+ abort();
+ CASE (const ScriptDataStr&, u)
+ {
+ RString p = u.str;
+ rv = atoi(p.c_str());
+ }
+ CASE (const ScriptDataInt&, u)
+ {
+ return u.numi;
+ }
+ CASE (const ScriptDataPos&, u)
+ {
+ return u.numi;
+ }
}
- // TODO see if I also need to return for other types?
- return data->get_if<ScriptDataInt>()->numi;
+ *data = ScriptDataInt{rv};
+ return rv;
}
static __attribute__((warn_unused_result))
diff --git a/tools/debug-debug-scripts b/tools/debug-debug-scripts
index 79520e9..e5eeb6c 100755
--- a/tools/debug-debug-scripts
+++ b/tools/debug-debug-scripts
@@ -1,7 +1,26 @@
#!/usr/bin/env python
-
+# encoding: utf-8
from __future__ import print_function
+copyright = '''
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+'''
+
import itertools
import os
import subprocess
@@ -57,8 +76,13 @@ def gen_test(name, expr, expected):
print('}')
def main(args):
- print('// Generated by', __file__)
+ print('// test.cpp - generated by', __file__)
+ print(copyright)
print('#include <cstdio>')
+ print('// just mention "fwd.hpp" and "../poison.hpp" to make formatter happy')
+ print('namespace tmwa')
+ print('{')
+ print('} // namespace tmwa')
print()
print('template<class T>')
print('__attribute__((noinline))')