From 54d593bf8027fce2490513f079c00d63d518a703 Mon Sep 17 00:00:00 2001 From: cavesomething Date: Sat, 15 May 2010 01:32:16 +0000 Subject: [PATCH] Add a check for the message length in dialogs and give a warning if it is exceeded (This should just result in truncation server-side) git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13218 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/dialog/dialog_check.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/dialog/dialog_check.py b/python/dialog/dialog_check.py index 6318de944..f62ec3266 100644 --- a/python/dialog/dialog_check.py +++ b/python/dialog/dialog_check.py @@ -13,6 +13,9 @@ import sys import os import re +# There is an upper limit on the maximum message length the server can cope with, exceeding it throws out a warning. +MAX_MSG_LENGTH = 2048 + def checkactionfile(filename, condition): args = condition[1:] checkstatus = 0 @@ -109,6 +112,12 @@ def checkdialoguefile(msgfile, location): errors+=1 elif action == "msg": + for line in jsonRule["msg"]: + if len(line) > MAX_MSG_LENGTH: + # We won't print out the entire line, because it's very + # very long, but we'll print the first 70 characters in order to help identify it + print "WARNING: A Dialog Line for rule", rulenumber, "is too long. (", len(line), "characters, maximum is", MAX_MSG_LENGTH, ") \nLine begins:", line[:70] + warnings+=1 msg+=1 elif action == "post": post+=1