diff --git a/CMakeLists.txt b/CMakeLists.txt index b5cb0793..1f5f6248 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,7 @@ set(ProjectName "startup") file(GLOB soruces src/*.cc) file(GLOB headers src/*.h) file(GLOB_RECURSE proto ./src/proto/*.proto) +file(GLOB_RECURSE pycli ./src/pycli/*.py) file(GLOB_RECURSE lua ./src/lua/*.lua) file(GLOB_RECURSE plugin ./config//plugin/*.xml) file(GLOB_RECURSE config ./config/node/*.json) @@ -169,6 +170,7 @@ source_group_by_dir(proto) source_group_by_dir(lua) source_group_by_dir(plugin) source_group_by_dir(config) +source_group_by_dir(pycli) add_executable(${ProjectName} ${soruces} ${headers} ${proto} ${lua} ${plugin} ${config}) diff --git a/config/plugin/backstage.xml b/config/plugin/backstage.xml index e7b38a0f..532ee8a1 100644 --- a/config/plugin/backstage.xml +++ b/config/plugin/backstage.xml @@ -3,6 +3,6 @@ - + diff --git a/config/plugin/db_proxy.xml b/config/plugin/db_proxy.xml index 8372ad3e..5176ebba 100644 --- a/config/plugin/db_proxy.xml +++ b/config/plugin/db_proxy.xml @@ -3,10 +3,10 @@ - - - - - + + + + + \ No newline at end of file diff --git a/config/plugin/ds_mgr.xml b/config/plugin/ds_mgr.xml index e0d01c6a..4af26fad 100644 --- a/config/plugin/ds_mgr.xml +++ b/config/plugin/ds_mgr.xml @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/config/plugin/game.xml b/config/plugin/game.xml index c860891d..ecee73c0 100644 --- a/config/plugin/game.xml +++ b/config/plugin/game.xml @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/config/plugin/master.xml b/config/plugin/master.xml index 2874b45d..a45007e4 100644 --- a/config/plugin/master.xml +++ b/config/plugin/master.xml @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/config/plugin/player.xml b/config/plugin/player.xml index b6ac8108..ead2d9e9 100644 --- a/config/plugin/player.xml +++ b/config/plugin/player.xml @@ -9,6 +9,6 @@ - + diff --git a/config/plugin/proxy.xml b/config/plugin/proxy.xml index a0689d10..4fbb6305 100644 --- a/config/plugin/proxy.xml +++ b/config/plugin/proxy.xml @@ -1,11 +1,10 @@ - - + \ No newline at end of file diff --git a/config/plugin/web.xml b/config/plugin/web.xml index ae4feadc..8fdc9cd2 100644 --- a/config/plugin/web.xml +++ b/config/plugin/web.xml @@ -3,7 +3,7 @@ - + diff --git a/config/plugin/world.xml b/config/plugin/world.xml index d079557f..452f6266 100644 --- a/config/plugin/world.xml +++ b/config/plugin/world.xml @@ -8,6 +8,6 @@ - + \ No newline at end of file diff --git a/docker/build_image.sh b/docker/build_image.sh index 17c72deb..aad99e15 100755 --- a/docker/build_image.sh +++ b/docker/build_image.sh @@ -3,22 +3,28 @@ cd $(dirname $0) source ../tools/common.sh -build_type='docker' +version=$1 +if [[ $version == "" ]];then + version="1.2" +fi + +dockerfile=./docker/src is_build_third_party=0 is_build_sqkctl=0 -src_image_tag=pwnsky/squick_src:1.1 -bin_image_tag=pwnsky/squick:1.1 +src_image_tag=pwnsky/squick_src:$version +bin_image_tag=pwnsky/squick:$version build_container=squick_src_build cd $project_path echo "Build src image" -docker build . -t $src_image_tag -f ./docker/src +docker build . -t $src_image_tag -f $dockerfile check_err echo "Export binary files" docker run -d --name $build_container $src_image_tag check_err +mkdir -p ./cache rm -rf ./cache/docker_deploy docker cp $build_container:/squick/deploy ./cache/docker_deploy check_err @@ -33,5 +39,9 @@ echo "Build release image" docker build . -t $bin_image_tag -f ./docker/release check_err +echo "Exporting the image" +docker save -o ./cache/squick_$version.tar pwnsky/squick:$version +check_err + echo "Build image ok" print_ok diff --git a/docker/release b/docker/release index bfe5f204..4622bd0c 100644 --- a/docker/release +++ b/docker/release @@ -1,18 +1,11 @@ -# cd {squick_project} -# docker build . -t i0gan/squick_src:1.1 -f ./docker/src -# docker run -d --name squick_src i0gan/squick_src:1.1 -# rm -rf ./cache/docker_deploy -# docker cp squick_src:/squick/deploy ./cache/docker_deploy - -# docker build . -t i0gan/squick:1.1 -f ./docker/release -# docker run -it --name squick i0gan/squick:1.1 - FROM ubuntu:22.04 + # Set env ARG DEBIAN_FRONTEND=noninteractive +RUN apt update && apt install -y dos2unix vim net-tools # copy from docker builded files COPY ./cache/docker_deploy /squick WORKDIR /squick RUN chmod +x /squick/script/*.sh -CMD bash /squick/script/squick.sh \ No newline at end of file +CMD bash /squick/script/squick.sh diff --git a/docker/release_mini b/docker/release_mini new file mode 100644 index 00000000..bfe5f204 --- /dev/null +++ b/docker/release_mini @@ -0,0 +1,18 @@ +# cd {squick_project} +# docker build . -t i0gan/squick_src:1.1 -f ./docker/src +# docker run -d --name squick_src i0gan/squick_src:1.1 +# rm -rf ./cache/docker_deploy +# docker cp squick_src:/squick/deploy ./cache/docker_deploy + +# docker build . -t i0gan/squick:1.1 -f ./docker/release +# docker run -it --name squick i0gan/squick:1.1 + +FROM ubuntu:22.04 +# Set env +ARG DEBIAN_FRONTEND=noninteractive + +# copy from docker builded files +COPY ./cache/docker_deploy /squick +WORKDIR /squick +RUN chmod +x /squick/script/*.sh +CMD bash /squick/script/squick.sh \ No newline at end of file diff --git a/docker/src_dep b/docker/src_dep new file mode 100644 index 00000000..3753f0ab --- /dev/null +++ b/docker/src_dep @@ -0,0 +1,15 @@ +FROM pwnsky/squick_src:1.1 + +COPY . /squick_dep + +RUN rm -rf /squick_dep/third_party && mv /squick/third_party /squick_dep && rm -rf /squick && mv /squick_dep /squick + +WORKDIR /squick +RUN cd tools && chmod +x *.sh && dos2unix *.sh +RUN cd script && chmod +x *.sh && dos2unix *.sh + +RUN bash ./tools/clean_squick.sh +RUN bash ./tools/build_sqkctl.sh +RUN bash ./tools/build_squick.sh +RUN bash ./tools/generate_deploy.sh +CMD bash /squick/script/squick.sh diff --git a/kubernetes/gen_k8s_config.sh b/kubernetes/gen_k8s_config.sh index 99b989f0..340f2e12 100755 --- a/kubernetes/gen_k8s_config.sh +++ b/kubernetes/gen_k8s_config.sh @@ -1,6 +1,9 @@ #! /bin/bash namespace="pwnsky" -image="pwnsky" +image="pwnsky/squick:1.1" + +rm -rf k8s_cfg +mkdir -p k8s_cfg diff --git a/kubernetes/tmpl/backstage.yaml b/kubernetes/tmpl/backstage.yaml new file mode 100644 index 00000000..1c565056 --- /dev/null +++ b/kubernetes/tmpl/backstage.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: backstage + namespace: default + labels: + app: squick +spec: + replicas: 1 + selector: + matchLabels: + app: squick + template: + metadata: + labels: + app: squick + spec: + containers: + - name: squick + image: pwnsky/squick:1.2 + imagePullPolicy: Never + command: ["/bin/bash", "-c"] + args: + - > + /squick/script/squick.sh type=backstage id=`expr 2500 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/kubernetes/node/master.yaml b/kubernetes/tmpl/db_proxy.yaml similarity index 75% rename from kubernetes/node/master.yaml rename to kubernetes/tmpl/db_proxy.yaml index ed71fb35..ceaa9427 100644 --- a/kubernetes/node/master.yaml +++ b/kubernetes/tmpl/db_proxy.yaml @@ -2,13 +2,12 @@ apiVersion: apps/v1 kind: StatefulSet metadata: - name: squick-master + name: db-proxy namespace: default labels: app: squick spec: - serviceName: "svc-squick-master" - replicas: 2 + replicas: 3 selector: matchLabels: app: squick @@ -19,12 +18,12 @@ spec: spec: containers: - name: squick - image: pwnsky/squick:1.1 + image: pwnsky/squick:1.2 imagePullPolicy: Never command: ["/bin/bash", "-c"] args: - > - /squick/script/squick.sh type=master id=1000${HOSTNAME##*-} area=0 ip=$(POD_IP) port=10001 http_port=50000 logshow=0 + /squick/script/squick.sh type=proxy id=`expr 2000 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0 env: - name: POD_NAME valueFrom: diff --git a/kubernetes/tmpl/master.yaml b/kubernetes/tmpl/master.yaml new file mode 100644 index 00000000..f2f78162 --- /dev/null +++ b/kubernetes/tmpl/master.yaml @@ -0,0 +1,53 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: squick-master + namespace: default + labels: + app: squick +spec: + serviceName: "svc-squick-master" + replicas: 3 + selector: + matchLabels: + app: squick + template: + metadata: + labels: + app: squick + spec: + containers: + - name: squick + image: pwnsky/squick:1.2 + imagePullPolicy: Never + command: ["/bin/bash", "-c"] + args: + - > + /squick/script/squick.sh type=master id=`expr 1 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10001 http_port=50000 logshow=0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace +--- +apiVersion: v1 +kind: Service +metadata: + name: svc-squick-master +spec: + selector: + app: squick + ports: + - protocol: TCP + port: 10001 + targetPort: 10001 + type: ClusterIP diff --git a/kubernetes/tmpl/player.yaml b/kubernetes/tmpl/player.yaml new file mode 100644 index 00000000..fe4ccee7 --- /dev/null +++ b/kubernetes/tmpl/player.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: squick-player + namespace: default + labels: + app: squick +spec: + #serviceName: "svc-squick-proxy" + replicas: 3 + selector: + matchLabels: + app: squick + template: + metadata: + labels: + app: squick + spec: + containers: + - name: squick + image: pwnsky/squick:1.2 + imagePullPolicy: Never + command: ["/bin/bash", "-c"] + args: + - > + /squick/script/squick.sh type=player id=`expr 1000 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10401 master_ip=svc-squick-master master_port=10001 logshow=0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/kubernetes/tmpl/proxy.yaml b/kubernetes/tmpl/proxy.yaml new file mode 100644 index 00000000..5cfe2919 --- /dev/null +++ b/kubernetes/tmpl/proxy.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: proxy + namespace: default + labels: + app: squick +spec: + #serviceName: "svc-squick-proxy" + replicas: 3 + selector: + matchLabels: + app: squick + template: + metadata: + labels: + app: squick + spec: + containers: + - name: squick + image: pwnsky/squick:1.2 + imagePullPolicy: Never + command: ["/bin/bash", "-c"] + args: + - > + /squick/script/squick.sh type=proxy id=`expr 500 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/kubernetes/tmpl/web.yaml b/kubernetes/tmpl/web.yaml new file mode 100644 index 00000000..d007a1d4 --- /dev/null +++ b/kubernetes/tmpl/web.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: web + namespace: default + labels: + app: squick +spec: + serviceName: "svc-squick-web" + replicas: 3 + selector: + matchLabels: + app: squick + template: + metadata: + labels: + app: squick + spec: + containers: + - name: squick + image: pwnsky/squick:1.2 + imagePullPolicy: Never + command: ["/bin/bash", "-c"] + args: + - > + /squick/script/squick.sh type=proxy id=`expr 2000 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/kubernetes/tmpl/world.yaml b/kubernetes/tmpl/world.yaml new file mode 100644 index 00000000..648ad298 --- /dev/null +++ b/kubernetes/tmpl/world.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: world + namespace: default + labels: + app: squick +spec: + serviceName: "svc-squick-web" + replicas: 3 + selector: + matchLabels: + app: squick + template: + metadata: + labels: + app: squick + spec: + containers: + - name: squick + image: pwnsky/squick:1.2 + imagePullPolicy: Never + command: ["/bin/bash", "-c"] + args: + - > + /squick/script/squick.sh type=world id=`expr 2000 + ${HOSTNAME##*-}` area=0 ip=$(POD_IP) port=10501 ws_port=10502 master_ip=svc-squick-master master_port=10001 logshow=0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/resource/excel/Group.xlsx b/resource/excel/Group.xlsx index 70021905..59dab188 100644 Binary files a/resource/excel/Group.xlsx and b/resource/excel/Group.xlsx differ diff --git a/resource/excel/Object.xlsx b/resource/excel/Object.xlsx new file mode 100644 index 00000000..f83bb0da Binary files /dev/null and b/resource/excel/Object.xlsx differ diff --git a/resource/excel/Player.xlsx b/resource/excel/Player.xlsx index 24005403..4f1ff835 100644 Binary files a/resource/excel/Player.xlsx and b/resource/excel/Player.xlsx differ diff --git a/resource/excel/Scene.xlsx b/resource/excel/Scene.xlsx index ff8ac005..d8c0de6b 100644 Binary files a/resource/excel/Scene.xlsx and b/resource/excel/Scene.xlsx differ diff --git a/resource/excel/common/IObject.xlsx b/resource/excel/common/IObject.xlsx index ef76d7cd..d95586bd 100644 Binary files a/resource/excel/common/IObject.xlsx and b/resource/excel/common/IObject.xlsx differ diff --git a/resource/excel/example/Property.xlsx b/resource/excel/example/Property.xlsx index cb63180d..fa41e721 100644 Binary files a/resource/excel/example/Property.xlsx and b/resource/excel/example/Property.xlsx differ diff --git a/resource/excel/example/Record.xlsx b/resource/excel/example/Record.xlsx index 4d7e1e6a..637423b2 100644 Binary files a/resource/excel/example/Record.xlsx and b/resource/excel/example/Record.xlsx differ diff --git a/src/lua/common/module_mgr.lua b/src/lua/common/module_mgr.lua index 0384d12a..08af5896 100644 --- a/src/lua/common/module_mgr.lua +++ b/src/lua/common/module_mgr.lua @@ -6,7 +6,8 @@ ----------------------------------------------------------------------------- ModuleMgr = { - modules = {} + modules = {}, + modules_info = {} } -- pre_path: 模块路径 @@ -27,14 +28,15 @@ function ModuleMgr:Register(pre_path, list) Squick:LogInfo("lua start to load " .. name); local old_module = ModuleMgr.modules[name] - local object = require(path); - if object then + local new_module = require(path); + if new_module then if old_module ~= nil then - Squick:LogInfo("reload " .. path.. " succeed"); - -- 只更新函数 + Squick:LogInfo("Begin hot reload " .. path); + self:HotReload(old_module, new_module) + Squick:LogInfo("Hot reload " .. path.. " succeed"); else - ModuleMgr.modules[name] = object -- 加载全部 + ModuleMgr.modules[name] = new_module -- 加载全部 Squick:LogInfo("load " .. path .. " succeed"); end else @@ -47,8 +49,13 @@ function ModuleMgr:Register(pre_path, list) return true end -function ModuleMgr:HotReload() - +function ModuleMgr:HotReload(old_module, new_module) + for key, value in pairs(new_module) do + if type(value) == "function" then + Squick:LogInfo("reloading function " .. key) + old_module[key] = value + end + end end function ModuleMgr:Start() diff --git a/src/lua/main.lua b/src/lua/main.lua index dff3b2da..effeb037 100644 --- a/src/lua/main.lua +++ b/src/lua/main.lua @@ -16,6 +16,7 @@ function Print(...) end function Require(file) + package.loaded[file] = nil require(file) end diff --git a/src/node/backstage/golib/go.mod b/src/node/backstage/golib/go.mod new file mode 100644 index 00000000..c433d081 --- /dev/null +++ b/src/node/backstage/golib/go.mod @@ -0,0 +1,38 @@ +module golib + +go 1.22.5 + +require ( + github.com/gin-gonic/gin v1.10.0 + github.com/go-pay/gopay v1.5.104 + github.com/go-pay/xlog v0.0.3 +) + +require ( + github.com/bytedance/sonic v1.11.6 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.20.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + golang.org/x/arch v0.8.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/src/node/backstage/golib/go.sum b/src/node/backstage/golib/go.sum new file mode 100644 index 00000000..f3f25113 --- /dev/null +++ b/src/node/backstage/golib/go.sum @@ -0,0 +1,95 @@ +github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/go-pay/gopay v1.5.104 h1:XMftoDnMf/2P3o11jYzqvAzAihum5fVPQVmQ6LgSeEY= +github.com/go-pay/gopay v1.5.104/go.mod h1:1Ywz2i8x96NrFa+F0TKDF7tQl7AZs4DxAc0kh069gJg= +github.com/go-pay/util v0.0.3 h1:0OjERb7MAVpM2gLPnBESLdMsosYyJ4i31V2/YZBiPjw= +github.com/go-pay/util v0.0.3/go.mod h1:qM8VbyF1n7YAPZBSJONSPMPsPedhUTktewUAdf1AjPg= +github.com/go-pay/xlog v0.0.3 h1:avyMhCL/JgBHreoGx/am/kHxfs1udDOAeVqbmzP/Yes= +github.com/go-pay/xlog v0.0.3/go.mod h1:mH47xbobrdsSHWsmFtSF5agWbMHFP+tK0ZbVCk5OAEw= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= +github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= +golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/src/node/backstage/golib/main.go b/src/node/backstage/golib/main.go new file mode 100644 index 00000000..51b9ea05 --- /dev/null +++ b/src/node/backstage/golib/main.go @@ -0,0 +1,38 @@ +package main + +import "C" + +import ( + "fmt" + "github.com/go-pay/gopay" + "github.com/go-pay/xlog" + "github.com/gin-gonic/gin" + "net/http" +) + +//export Func +func Func(input int){ + fmt.Println("I am Func, hello world,input ",input, " over") + xlog.Info("GoPay Version: ", gopay.Version) +} + +//export HttpRun +func HttpRun() { + xlog.Info("Hello world 2") + + router := gin.Default() + router.GET("/loop", func(c *gin.Context) { + i := 0 + for { + i++ + c.JSON(http.StatusOK, gin.H{ + "message": "Hello, World!", + "counter": i, + }) + break // 在这个例子中,我们只循环一次,然后退出 + } + }) + go router.Run(":8080") +} + +func main() {} diff --git a/src/node/proxy/logic/logic_module.cc b/src/node/proxy/logic/logic_module.cc index 38347a67..b7455d64 100644 --- a/src/node/proxy/logic/logic_module.cc +++ b/src/node/proxy/logic/logic_module.cc @@ -14,7 +14,6 @@ bool LogicModule::Destroy() { return true; } bool LogicModule::Update() { return true; } bool LogicModule::AfterStart() { - m_class_ = pm_->FindModule(); m_net_ = pm_->FindModule(); m_net_client_ = pm_->FindModule(); m_log_ = pm_->FindModule(); diff --git a/src/node/proxy/logic/logic_module.h b/src/node/proxy/logic/logic_module.h index 8f5e8fac..10cecf06 100644 --- a/src/node/proxy/logic/logic_module.h +++ b/src/node/proxy/logic/logic_module.h @@ -95,7 +95,6 @@ class LogicModule : public ILogicModule { protected: ILogModule *m_log_; - IClassModule *m_class_; IScheduleModule *m_schedule_; INetModule *m_net_; IWSModule *m_ws_; diff --git a/src/squick/core/i_property.h b/src/squick/core/i_property.h index 3235bcbf..74b22d9d 100644 --- a/src/squick/core/i_property.h +++ b/src/squick/core/i_property.h @@ -29,21 +29,6 @@ class _SquickExport IProperty : public MemoryCounter { virtual const DATA_TYPE GetType() const = 0; virtual const bool GeUsed() const = 0; virtual const std::string &GetKey() const = 0; - virtual const bool GetSave() const = 0; - virtual const bool GetPublic() const = 0; - virtual const bool GetPrivate() const = 0; - virtual const bool GetCache() const = 0; - virtual const bool GetRef() const = 0; - virtual const bool GetForce() const = 0; - virtual const bool GetUpload() const = 0; - - virtual void SetSave(bool bSave) = 0; - virtual void SetPublic(bool bPublic) = 0; - virtual void SetPrivate(bool bPrivate) = 0; - virtual void SetCache(bool bCache) = 0; - virtual void SetRef(bool bRef) = 0; - virtual void SetForce(bool bRef) = 0; - virtual void SetUpload(bool bUpload) = 0; virtual INT64 GetInt() const = 0; virtual int GetInt32() const = 0; diff --git a/src/squick/core/i_record.h b/src/squick/core/i_record.h index 076fadcc..8c3d7985 100644 --- a/src/squick/core/i_record.h +++ b/src/squick/core/i_record.h @@ -144,26 +144,10 @@ class _SquickExport IRecord : public MemoryCounter { virtual bool Clear() = 0; virtual void AddRecordHook(const RECORD_EVENT_FUNCTOR_PTR &cb) = 0; - - virtual const bool GetSave() = 0; - virtual const bool GetPublic() = 0; - virtual const bool GetPrivate() = 0; - virtual const bool GetCache() = 0; - virtual const bool GetRef() = 0; - virtual const bool GetForce() = 0; - virtual const bool GetUpload() = 0; virtual const std::string &GetName() const = 0; virtual std::shared_ptr GetStartData() const = 0; virtual const std::shared_ptr GetTag() const = 0; - - virtual void SetSave(const bool bSave) = 0; - virtual void SetCache(const bool bCache) = 0; - virtual void SetRef(const bool bRef) = 0; - virtual void SetForce(const bool bForce) = 0; - virtual void SetUpload(const bool bUpload) = 0; - virtual void SetPublic(const bool bPublic) = 0; - virtual void SetPrivate(const bool bPrivate) = 0; virtual void SetName(const std::string &name) = 0; virtual const TRECORDVEC &GetRecordVec() const = 0; diff --git a/src/squick/core/property.cc b/src/squick/core/property.cc index f134cdfc..06056489 100644 --- a/src/squick/core/property.cc +++ b/src/squick/core/property.cc @@ -80,34 +80,6 @@ const SquickData &Property::GetValue() const { const std::string &Property::GetKey() const { return msPropertyName; } -const bool Property::GetSave() const { return mbSave; } - -const bool Property::GetPublic() const { return mbPublic; } - -const bool Property::GetPrivate() const { return mbPrivate; } - -const bool Property::GetCache() const { return mbCache; } - -const bool Property::GetRef() const { return mbRef; } - -const bool Property::GetForce() const { return mbForce; } - -const bool Property::GetUpload() const { return mbUpload; } - -void Property::SetSave(bool bSave) { mbSave = bSave; } - -void Property::SetPublic(bool bPublic) { mbPublic = bPublic; } - -void Property::SetPrivate(bool bPrivate) { mbPrivate = bPrivate; } - -void Property::SetCache(bool bCache) { mbCache = bCache; } - -void Property::SetRef(bool bRef) { mbRef = bRef; } - -void Property::SetForce(bool bRef) { mbForce = bRef; } - -void Property::SetUpload(bool bUpload) { mbUpload = bUpload; } - INT64 Property::GetInt() const { if (!mxData) { return 0; diff --git a/src/squick/core/property.h b/src/squick/core/property.h index fe9ec03c..7507a569 100644 --- a/src/squick/core/property.h +++ b/src/squick/core/property.h @@ -31,21 +31,6 @@ class _SquickExport Property : public IProperty { virtual const DATA_TYPE GetType() const; virtual const bool GeUsed() const; virtual const std::string &GetKey() const; - virtual const bool GetSave() const; - virtual const bool GetPublic() const; - virtual const bool GetPrivate() const; - virtual const bool GetCache() const; - virtual const bool GetRef() const; - virtual const bool GetForce() const; - virtual const bool GetUpload() const; - - virtual void SetSave(bool bSave); - virtual void SetPublic(bool bPublic); - virtual void SetPrivate(bool bPrivate); - virtual void SetCache(bool bCache); - virtual void SetRef(bool bRef); - virtual void SetForce(bool bRef); - virtual void SetUpload(bool bUpload); virtual INT64 GetInt() const; virtual int GetInt32() const; diff --git a/src/squick/core/property_manager.cc b/src/squick/core/property_manager.cc index 81a36d2e..fe31f6b9 100644 --- a/src/squick/core/property_manager.cc +++ b/src/squick/core/property_manager.cc @@ -21,13 +21,6 @@ std::shared_ptr PropertyManager::AddProperty(const Guid &self, std::s if (!pOldProperty) { std::shared_ptr pNewProperty(new Property(self, propertyName, pProperty->GetType())); - pNewProperty->SetPublic(pProperty->GetPublic()); - pNewProperty->SetPrivate(pProperty->GetPrivate()); - pNewProperty->SetSave(pProperty->GetSave()); - pNewProperty->SetCache(pProperty->GetCache()); - pNewProperty->SetRef(pProperty->GetRef()); - pNewProperty->SetUpload(pProperty->GetUpload()); - this->AddElement(propertyName, pNewProperty); } diff --git a/src/squick/core/record.cc b/src/squick/core/record.cc index e1c49600..a6617841 100644 --- a/src/squick/core/record.cc +++ b/src/squick/core/record.cc @@ -1134,38 +1134,11 @@ bool Record::Clear() { void Record::AddRecordHook(const RECORD_EVENT_FUNCTOR_PTR &cb) { mtRecordCallback.push_back(cb); } -const bool Record::GetSave() { return mbSave; } - -const bool Record::GetCache() { return mbCache; } - -const bool Record::GetRef() { return mbRef; } - -const bool Record::GetForce() { return mbForce; } - -const bool Record::GetUpload() { return mbUpload; } - -const bool Record::GetPublic() { return mbPublic; } - -const bool Record::GetPrivate() { return mbPrivate; } int Record::GetPos(int row, int col) const { return row * mVarRecordType->GetCount() + col; } const std::string &Record::GetName() const { return mstrRecordName; } -void Record::SetSave(const bool bSave) { mbSave = bSave; } - -void Record::SetCache(const bool bCache) { mbCache = bCache; } - -void Record::SetRef(const bool bRef) { mbRef = bRef; } - -void Record::SetForce(const bool bForce) { mbForce = bForce; } - -void Record::SetUpload(const bool bUpload) { mbUpload = bUpload; } - -void Record::SetPublic(const bool bPublic) { mbPublic = bPublic; } - -void Record::SetPrivate(const bool bPrivate) { mbPrivate = bPrivate; } - void Record::SetName(const std::string &name) { mstrRecordName = name; } std::shared_ptr Record::GetStartData() const { diff --git a/src/squick/core/record.h b/src/squick/core/record.h index 9f2aa41f..45d68d4b 100644 --- a/src/squick/core/record.h +++ b/src/squick/core/record.h @@ -109,36 +109,9 @@ class _SquickExport Record : public IRecord { virtual void AddRecordHook(const RECORD_EVENT_FUNCTOR_PTR &cb); - virtual const bool GetSave(); - - virtual const bool GetCache(); - - virtual const bool GetRef(); - - virtual const bool GetForce(); - - virtual const bool GetUpload(); - - virtual const bool GetPublic(); - - virtual const bool GetPrivate(); virtual const std::string &GetName() const; - virtual void SetSave(const bool bSave); - - virtual void SetCache(const bool bCache); - - virtual void SetRef(const bool bRef); - - virtual void SetForce(const bool bForce); - - virtual void SetUpload(const bool bUpload); - - virtual void SetPublic(const bool bPublic); - - virtual void SetPrivate(const bool bPrivate); - virtual void SetName(const std::string &name); virtual std::shared_ptr GetStartData() const; diff --git a/src/squick/plugin/config/class_module.cc b/src/squick/plugin/config/class_module.cc index 0843b004..5dac78c7 100644 --- a/src/squick/plugin/config/class_module.cc +++ b/src/squick/plugin/config/class_module.cc @@ -6,20 +6,18 @@ #include #include #include -ClassModule::ClassModule() { mConfigFileName = "config/struct/logic_class.xml"; } +ClassModule::ClassModule() { mConfigFileName = "config/struct/Root.xml"; } ClassModule::ClassModule(IPluginManager *p) { pm_ = p; - mConfigFileName = "config/struct/logic_class.xml"; + mConfigFileName = "config/struct/Root.xml"; #ifdef DEBUG std::cout << "Using [" << pm_->GetWorkPath() << "/" + mConfigFileName << "]" << std::endl; #endif if (!this->mbBackup) { - // IThreadPoolModule *threadPoolModule = pm_->FindModule(); - // const int threadCount = threadPoolModule->GetThreadCount(); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < CONFIG_DATA_THREADS_CAN_BE_USED_CNT; ++i) { ThreadClassModule threadElement; threadElement.used = false; threadElement.classModule = new ClassModule(); @@ -64,6 +62,7 @@ bool ClassModule::Destroy() { return true; } +// Get a free class module for find IClassModule *ClassModule::GetThreadClassModule() { std::thread::id threadID = std::this_thread::get_id(); @@ -73,12 +72,12 @@ IClassModule *ClassModule::GetThreadClassModule() { return mThreadClasses[i].classModule; } } else { + // init for this thread mThreadClasses[i].used = true; mThreadClasses[i].threadID = threadID; return mThreadClasses[i].classModule; } } - return nullptr; } @@ -117,21 +116,6 @@ bool ClassModule::AddProperties(rapidxml::xml_node<> *pPropertyRootNode, std::sh } const char *pstrType = pPropertyNode->first_attribute("Type")->value(); - const char *pstrPublic = pPropertyNode->first_attribute("Public")->value(); - const char *pstrPrivate = pPropertyNode->first_attribute("Private")->value(); - const char *pstrSave = pPropertyNode->first_attribute("Save")->value(); - const char *pstrCache = pPropertyNode->first_attribute("Cache")->value(); - const char *pstrRef = pPropertyNode->first_attribute("Ref")->value(); - const char *pstrForce = pPropertyNode->first_attribute("Force")->value(); - const char *pstrUpload = pPropertyNode->first_attribute("Upload")->value(); - - bool bPublic = lexical_cast(pstrPublic); - bool bPrivate = lexical_cast(pstrPrivate); - bool bSave = lexical_cast(pstrSave); - bool bCache = lexical_cast(pstrCache); - bool bRef = lexical_cast(pstrRef); - bool bForce = lexical_cast(pstrForce); - bool bUpload = lexical_cast(pstrUpload); SquickData varProperty; if (TDATA_UNKNOWN == ComputerType(pstrType, varProperty)) { @@ -143,13 +127,6 @@ bool ClassModule::AddProperties(rapidxml::xml_node<> *pPropertyRootNode, std::sh // printf( " Property:%s[%s]\n", propertyName, pstrType ); std::shared_ptr xProperty = pClass->GetPropertyManager()->AddProperty(Guid(), propertyName, varProperty.GetType()); - xProperty->SetPublic(bPublic); - xProperty->SetPrivate(bPrivate); - xProperty->SetSave(bSave); - xProperty->SetCache(bCache); - xProperty->SetRef(bRef); - xProperty->SetForce(bForce); - xProperty->SetUpload(bUpload); } } @@ -171,28 +148,13 @@ bool ClassModule::AddRecords(rapidxml::xml_node<> *pRecordRootNode, std::shared_ const char *pstrRow = pRecordNode->first_attribute("Row")->value(); const char *pstrCol = pRecordNode->first_attribute("Col")->value(); - - const char *pstrPublic = pRecordNode->first_attribute("Public")->value(); - const char *pstrPrivate = pRecordNode->first_attribute("Private")->value(); - const char *pstrSave = pRecordNode->first_attribute("Save")->value(); - const char *pstrCache = pRecordNode->first_attribute("Cache")->value(); - const char *pstrRef = pRecordNode->first_attribute("Ref")->value(); - const char *pstrForce = pRecordNode->first_attribute("Force")->value(); - const char *pstrUpload = pRecordNode->first_attribute("Upload")->value(); + std::string strView; if (pRecordNode->first_attribute("View") != NULL) { strView = pRecordNode->first_attribute("View")->value(); } - bool bPublic = lexical_cast(pstrPublic); - bool bPrivate = lexical_cast(pstrPrivate); - bool bSave = lexical_cast(pstrSave); - bool bCache = lexical_cast(pstrCache); - bool bRef = lexical_cast(pstrCache); - bool bForce = lexical_cast(pstrCache); - bool bUpload = lexical_cast(pstrUpload); - std::shared_ptr recordVar(new DataList()); std::shared_ptr recordTag(new DataList()); @@ -216,14 +178,7 @@ bool ClassModule::AddRecords(rapidxml::xml_node<> *pRecordRootNode, std::shared_ } std::shared_ptr xRecord = pClass->GetRecordManager()->AddRecord(Guid(), pstrRecordName, recordVar, recordTag, atoi(pstrRow)); - - xRecord->SetPublic(bPublic); - xRecord->SetPrivate(bPrivate); - xRecord->SetSave(bSave); - xRecord->SetCache(bCache); - xRecord->SetRef(bRef); - xRecord->SetForce(bForce); - xRecord->SetUpload(bUpload); + } } diff --git a/src/squick/plugin/config/element_module.cc b/src/squick/plugin/config/element_module.cc index 70785180..d9ef7946 100644 --- a/src/squick/plugin/config/element_module.cc +++ b/src/squick/plugin/config/element_module.cc @@ -16,7 +16,7 @@ ElementModule::ElementModule(IPluginManager *p) { mbLoaded = false; if (!this->mbBackup) { - for (int i = 0; i < pm_->GetAppCPUCount(); ++i) { + for (int i = 0; i < CONFIG_DATA_THREADS_CAN_BE_USED_CNT; ++i) { ThreadElementModule threadElement; threadElement.used = false; threadElement.elementModule = new ElementModule(this); @@ -84,6 +84,11 @@ bool ElementModule::Destroy() { return true; } +bool ElementModule::Reload(int type) +{ + return true; +} + IElementModule *ElementModule::GetThreadElementModule() { std::thread::id threadID = std::this_thread::get_id(); @@ -162,30 +167,6 @@ bool ElementModule::Load() { } bool ElementModule::CheckRef() { - std::shared_ptr pLogicClass = m_class_->First(); - while (pLogicClass) { - std::shared_ptr pClassPropertyManager = pLogicClass->GetPropertyManager(); - if (pClassPropertyManager) { - std::shared_ptr pProperty = pClassPropertyManager->First(); - while (pProperty) { - // if one property is ref,check every config - if (pProperty->GetRef()) { - const std::vector &strIdList = pLogicClass->GetIDList(); - for (int i = 0; i < strIdList.size(); ++i) { - const std::string &strId = strIdList[i]; - - const std::string &strRefValue = this->GetPropertyString(strId, pProperty->GetKey()); - if (!strRefValue.empty() && !this->GetElement(strRefValue)) { - LOG_FATAL("Check ref<%v> failed, class_name<%v> id<%v>", strRefValue, pLogicClass->GetClassName(), strId); - } - } - } - pProperty = pClassPropertyManager->Next(); - } - } - ////////////////////////////////////////////////////////////////////////// - pLogicClass = m_class_->Next(); - } return false; } @@ -238,14 +219,6 @@ bool ElementModule::Load(rapidxml::xml_node<> *attrNode, std::shared_ptr std::shared_ptr xRecord = pElementRecordManager->AddRecord(Guid(), pRecord->GetName(), pRecord->GetStartData(), pRecord->GetTag(), pRecord->GetRows()); - xRecord->SetPublic(pRecord->GetPublic()); - xRecord->SetPrivate(pRecord->GetPrivate()); - xRecord->SetSave(pRecord->GetSave()); - xRecord->SetCache(pRecord->GetCache()); - xRecord->SetRef(pRecord->GetRef()); - xRecord->SetForce(pRecord->GetForce()); - xRecord->SetUpload(pRecord->GetUpload()); - pRecord = pClassRecordManager->Next(); } } diff --git a/src/squick/plugin/config/element_module.h b/src/squick/plugin/config/element_module.h index 935611f7..c546503e 100644 --- a/src/squick/plugin/config/element_module.h +++ b/src/squick/plugin/config/element_module.h @@ -19,7 +19,7 @@ #include class Class; - +#define CONFIG_DATA_THREADS_CAN_BE_USED_CNT 1 class ElementConfigInfo { public: ElementConfigInfo() { @@ -55,6 +55,7 @@ class ElementModule : public IElementModule, MapEx #include +#include #include "net.h" @@ -313,10 +314,65 @@ bool Net::AddNetObject(const socket_t sock, NetObject *pObject) { return mmObject.insert(std::map::value_type(sock, pObject)).second; } +bool Net::IsValidIP(const std::string& ip) { + std::regex ip_regex( + "^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" // 1-3 numbers + "(?:\\." + "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" // 1-3 numbers + "){3}" // repeate 3 group + "(?:\\." + "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" // 1-3 numbers + ")$" // end + ); + + return std::regex_match(ip, ip_regex); +} + +bool Net::IsValidDomain(const std::string& domain) { + std::regex domain_regex( + "[a-zA-Z0-9]+" + "(?:\\.[a-zA-Z0-9]+)+" + ); + + return std::regex_match(domain, domain_regex); +} + +std::string Net::GetIpByDomain(std::string domain) { + + struct hostent *hptr; + hptr = gethostbyname(domain.c_str()); + if (hptr == NULL) { + //printf("gethostbyname error for host: %s: %s\n", domain.c_str(), hstrerror(h_errno)); + return ""; + } + + char **pptr; + char str[INET_ADDRSTRLEN]; + // for (pptr=hptr->h_aliases; *pptr!=NULL; pptr++) + // { + // printf("\ttalias: %s\n", *pptr); + // } + + // output ip + for (pptr = hptr->h_addr_list; *pptr!=NULL; pptr++) + { + std::string ip = inet_ntop(hptr->h_addrtype, *pptr, str, sizeof(str)); + return ip; + } + + return ""; +} + int Net::StartClientNet() { std::string ip = mstrIP; int nPort = mnPort; + if (!IsValidIP(ip)) + { + // domain to ip + ip = GetIpByDomain(ip); + } + struct sockaddr_in addr; struct bufferevent *bev = NULL; diff --git a/src/squick/plugin/net/net.h b/src/squick/plugin/net/net.h index b4c44f61..ac2b7cb6 100644 --- a/src/squick/plugin/net/net.h +++ b/src/squick/plugin/net/net.h @@ -87,6 +87,9 @@ class Net : public INet { int StartClientNet(); int StartServerNet(); void CloseObject(const socket_t sock); + bool IsValidIP(const std::string& ip); + bool IsValidDomain(const std::string& domain); + std::string GetIpByDomain(std::string domain); static void listener_cb(struct evconnlistener *listener, evutil_socket_t fd, struct sockaddr *sa, int socklen, void *user_data); static void conn_readcb(struct bufferevent *bev, void *user_data); diff --git a/src/squick/plugin/world/cell_module.cc b/src/squick/plugin/world/cell_module.cc index 5a84df6a..c7ec4f5e 100644 --- a/src/squick/plugin/world/cell_module.cc +++ b/src/squick/plugin/world/cell_module.cc @@ -17,7 +17,7 @@ bool CellModule::Start() { } bool CellModule::AfterStart() { - m_world_->AddClassCallBack(excel::Player::ThisName(), this, &CellModule::OnObjectEvent); + m_world_->AddClassCallBack(excel::Object::ThisName(), this, &CellModule::OnObjectEvent); // NF SYNC /*X @@ -376,15 +376,14 @@ int CellModule::AddMoveOutEventCallBack(CELL_MOVE_EVENT_FUNCTOR_PTR functorPtr) int CellModule::OnObjectEvent(const Guid &self, const std::string &classNames, const CLASS_OBJECT_EVENT classEvent, const DataList &var) { if (CLASS_OBJECT_EVENT::COE_CREATE_FINISH == classEvent) { - m_world_->AddPropertyCallBack(self, excel::IObject::Position(), this, &CellModule::OnPositionEvent); + m_world_->AddPropertyCallBack(self, excel::Object::Position(), this, &CellModule::OnPositionEvent); } - return 0; } int CellModule::OnPositionEvent(const Guid &self, const std::string &propertyName, const SquickData &oldVar, const SquickData &newVar, const INT64 reason) { - const int sceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID()); - const int groupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID()); + const int sceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID()); + const int groupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID()); const Vector3 &oldVec = oldVar.GetVector3(); const Vector3 &newVec = newVar.GetVector3(); diff --git a/src/squick/plugin/world/data_tail_module.cc b/src/squick/plugin/world/data_tail_module.cc index daedd95b..4ff42264 100644 --- a/src/squick/plugin/world/data_tail_module.cc +++ b/src/squick/plugin/world/data_tail_module.cc @@ -21,7 +21,7 @@ bool DataTailModule::Update() { return true; } bool DataTailModule::AfterStart() { #ifdef SQUICK_DEBUG_MODE - m_world_->AddClassCallBack(excel::Player::ThisName(), this, &DataTailModule::OnClassObjectEvent); + m_world_->AddClassCallBack(excel::Object::ThisName(), this, &DataTailModule::OnClassObjectEvent); #endif return true; } diff --git a/src/squick/plugin/world/scene_module.cc b/src/squick/plugin/world/scene_module.cc index 021d8f3f..3e3a214f 100644 --- a/src/squick/plugin/world/scene_module.cc +++ b/src/squick/plugin/world/scene_module.cc @@ -76,13 +76,6 @@ int SceneModule::RequestGroupScene(const int sceneID) { std::shared_ptr xProperty = pPropertyManager->AddProperty(ident, pStaticConfigPropertyInfo->GetKey(), pStaticConfigPropertyInfo->GetType()); - xProperty->SetPublic(pStaticConfigPropertyInfo->GetPublic()); - xProperty->SetPrivate(pStaticConfigPropertyInfo->GetPrivate()); - xProperty->SetSave(pStaticConfigPropertyInfo->GetSave()); - xProperty->SetCache(pStaticConfigPropertyInfo->GetCache()); - xProperty->SetRef(pStaticConfigPropertyInfo->GetRef()); - xProperty->SetUpload(pStaticConfigPropertyInfo->GetUpload()); - PROPERTY_EVENT_FUNCTOR functor = std::bind(&SceneModule::OnScenePropertyCommonEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5); PROPERTY_EVENT_FUNCTOR_PTR functorPtr(new PROPERTY_EVENT_FUNCTOR(functor)); @@ -96,11 +89,6 @@ int SceneModule::RequestGroupScene(const int sceneID) { std::shared_ptr xRecord = pRecordManager->AddRecord(ident, pConfigRecordInfo->GetName(), pConfigRecordInfo->GetStartData(), pConfigRecordInfo->GetTag(), pConfigRecordInfo->GetRows()); - xRecord->SetPublic(pConfigRecordInfo->GetPublic()); - xRecord->SetPrivate(pConfigRecordInfo->GetPrivate()); - xRecord->SetSave(pConfigRecordInfo->GetSave()); - xRecord->SetCache(pConfigRecordInfo->GetCache()); - xRecord->SetUpload(pConfigRecordInfo->GetUpload()); RECORD_EVENT_FUNCTOR functor = std::bind(&SceneModule::OnSceneRecordCommonEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4); @@ -131,8 +119,8 @@ bool SceneModule::RequestEnterScene(const Guid &self, const int sceneID, const i return false; } - const int nNowSceneID = m_world_->GetPropertyInt32(self, excel::Player::SceneID()); - const int nNowGroupID = m_world_->GetPropertyInt32(self, excel::Player::GroupID()); + const int nNowSceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID()); + const int nNowGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID()); if (nNowSceneID == sceneID && nNowGroupID == groupID) { LOG_INFO("Guid<%v> in same scene and group but it not a clone scene<%v>, group_id<%v> ", self.ToString(), sceneID, groupID); @@ -208,7 +196,7 @@ bool SceneModule::LeaveSceneGroup(const Guid &self) { } ///////// - const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::IObject::Position()); + const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::Object::Position()); BeforeLeaveSceneGroup(self, nOldSceneID, nOldGroupID, 0, DataList::Empty()); const Guid lastCell = m_pCellModule->ComputeCellID(lastPos); @@ -406,7 +394,7 @@ bool SceneModule::CreateSceneNPC(const int sceneID, const int groupID, const Dat int nWeight = m_world_->Random(0, 100); if (nWeight <= pResource->nWeight) { DataList arg; - arg << excel::IObject::Position() << pResource->vSeedPos; + arg << excel::Object::Position() << pResource->vSeedPos; // arg << SquickProtocol::NPC::SeedID() << pResource->seedID; arg.Append(argList); @@ -928,7 +916,7 @@ bool SceneModule::SwitchScene(const Guid &self, const int nTargetSceneID, const } ///////// - const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::IObject::Position()); + const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::Object::Position()); BeforeLeaveSceneGroup(self, nOldSceneID, nOldGroupID, type, arg); const Guid lastCell = m_pCellModule->ComputeCellID(lastPos); @@ -956,7 +944,7 @@ bool SceneModule::SwitchScene(const Guid &self, const int nTargetSceneID, const const Guid newCell = m_pCellModule->ComputeCellID(v); OnMoveCellEvent(self, nTargetGroupID, nTargetGroupID, Guid(), newCell); - pObject->SetPropertyVector3(excel::IObject::MoveTo(), v); + pObject->SetPropertyVector3(excel::Object::MoveTo(), v); ///////// AfterEnterSceneGroup(self, nTargetSceneID, nTargetGroupID, type, arg); @@ -1016,15 +1004,15 @@ int SceneModule::OnSceneRecordCommonEvent(const Guid &self, const RECORD_EVENT_D int SceneModule::OnPropertyCommonEvent(const Guid &self, const std::string &propertyName, const SquickData &oldVar, const SquickData &newVar, const INT64 reason) { - const std::string &className = m_world_->GetPropertyString(self, excel::IObject::ClassName()); - if (className == excel::Player::ThisName()) { + const std::string &className = m_world_->GetPropertyString(self, excel::Object::ClassName()); + if (className == excel::Object::ThisName()) { // only player can change grupid and sceneid - if (excel::Player::GroupID() == propertyName) { + if (excel::Object::GroupID() == propertyName) { OnPlayerGroupEvent(self, propertyName, oldVar, newVar); return 0; } - if (excel::Player::SceneID() == propertyName) { + if (excel::Object::SceneID() == propertyName) { OnPlayerSceneEvent(self, propertyName, oldVar, newVar); return 0; } @@ -1043,7 +1031,7 @@ int SceneModule::OnPropertyCommonEvent(const Guid &self, const std::string &prop int SceneModule::OnRecordCommonEvent(const Guid &self, const RECORD_EVENT_DATA &eventData, const SquickData &oldVar, const SquickData &newVar) { const std::string &recordName = eventData.recordName; - int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Player::GroupID()); + int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID()); if (nObjectGroupID < 0) { return 0; @@ -1059,14 +1047,14 @@ int SceneModule::OnRecordCommonEvent(const Guid &self, const RECORD_EVENT_DATA & int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &className, const CLASS_OBJECT_EVENT classEvent, const DataList &var) { if (CLASS_OBJECT_EVENT::COE_DESTROY == classEvent) { - const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID()); - const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID()); + const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID()); + const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID()); if (nObjectGroupID < 0 || nObjectSceneID <= 0) { return 0; } - const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Player::Position()); + const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Object::Position()); DataList valueAllPlayrNoSelfList; m_pCellModule->GetCellObjectList(nObjectSceneID, nObjectGroupID, pos, valueAllPlayrNoSelfList, true, self); @@ -1082,7 +1070,7 @@ int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &classNa DataList selfVar; selfVar << self; - if (className == excel::Player::ThisName()) { + if (className == excel::Object::ThisName()) { // tell youself, u want to enter this scene or this group OnObjectListEnter(selfVar, selfVar); @@ -1092,13 +1080,13 @@ int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &classNa OnObjectListEnterFinished(selfVar, selfVar); } else { - const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID()); - const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID()); + const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID()); + const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID()); if (nObjectGroupID < 0 || nObjectSceneID <= 0) { return 0; } - const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Player::Position()); + const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Object::Position()); DataList valueAllPlayrObjectList; m_pCellModule->GetCellObjectList(nObjectSceneID, nObjectGroupID, pos, valueAllPlayrObjectList, true); @@ -1117,8 +1105,8 @@ int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &classNa int SceneModule::OnPlayerGroupEvent(const Guid &self, const std::string &propertyName, const SquickData &oldVar, const SquickData &newVar) { // this event only happened in the same scene - const int sceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID()); - const Vector3 position = m_world_->GetPropertyVector3(self, excel::IObject::Position()); + const int sceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID()); + const Vector3 position = m_world_->GetPropertyVector3(self, excel::Object::Position()); int nOldGroupID = oldVar.GetInt32(); int nNewGroupID = newVar.GetInt32(); @@ -1218,11 +1206,11 @@ int SceneModule::OnPlayerSceneEvent(const Guid &self, const std::string &propert } int SceneModule::GetBroadCastObject(const Guid &self, const std::string &propertyName, const bool bTable, DataList &valueObject) { - const int nObjectContainerID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID()); - const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID()); - const Vector3 &position = m_world_->GetPropertyVector3(self, excel::IObject::Position()); + const int nObjectContainerID = m_world_->GetPropertyInt32(self, excel::Object::SceneID()); + const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID()); + const Vector3 &position = m_world_->GetPropertyVector3(self, excel::Object::Position()); - const std::string &className = m_world_->GetPropertyString(self, excel::IObject::ClassName()); + const std::string &className = m_world_->GetPropertyString(self, excel::Object::ClassName()); std::shared_ptr pClassRecordManager = m_class_->GetClassRecordManager(className); std::shared_ptr pClassPropertyManager = m_class_->GetClassPropertyManager(className); @@ -1250,27 +1238,27 @@ int SceneModule::GetBroadCastObject(const Guid &self, const std::string &propert if (bTable) { // upload property can not board to itself // if (pRecord->GetUpload()) - { - if (pRecord->GetPublic()) { - m_pCellModule->GetCellObjectList(nObjectContainerID, nObjectGroupID, position, valueObject, true, self); - } - - if (pRecord->GetPrivate()) { - valueObject.Add(self); - } - } + // { + // if (pRecord->GetPublic()) { + // m_pCellModule->GetCellObjectList(nObjectContainerID, nObjectGroupID, position, valueObject, true, self); + // } + + // if (pRecord->GetPrivate()) { + // valueObject.Add(self); + // } + // } } else { // upload property can not board to itself // if (pProperty->GetUpload()) - { - if (pProperty->GetPublic()) { - m_pCellModule->GetCellObjectList(nObjectContainerID, nObjectGroupID, position, valueObject, true, self); - } - - if (pProperty->GetPrivate()) { - valueObject.Add(self); - } - } + // { + // if (pProperty->GetPublic()) { + // m_pCellModule->GetCellObjectList(nObjectContainerID, nObjectGroupID, position, valueObject, true, self); + // } + + // if (pProperty->GetPrivate()) { + // valueObject.Add(self); + // } + // } } return valueObject.GetCount(); diff --git a/src/squick/plugin/world/world_module.cc b/src/squick/plugin/world/world_module.cc index 925dc7dd..a972deed 100644 --- a/src/squick/plugin/world/world_module.cc +++ b/src/squick/plugin/world/world_module.cc @@ -125,13 +125,6 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s std::shared_ptr xProperty = pPropertyManager->AddProperty(ident, pStaticConfigPropertyInfo->GetKey(), pStaticConfigPropertyInfo->GetType()); - xProperty->SetPublic(pStaticConfigPropertyInfo->GetPublic()); - xProperty->SetPrivate(pStaticConfigPropertyInfo->GetPrivate()); - xProperty->SetSave(pStaticConfigPropertyInfo->GetSave()); - xProperty->SetCache(pStaticConfigPropertyInfo->GetCache()); - xProperty->SetRef(pStaticConfigPropertyInfo->GetRef()); - xProperty->SetUpload(pStaticConfigPropertyInfo->GetUpload()); - // pObject->AddPropertyCallBack(pStaticConfigPropertyInfo->GetKey(), this, &WorldModule::OnPropertyCommonEvent); @@ -142,13 +135,6 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s while (pConfigRecordInfo) { std::shared_ptr xRecord = pRecordManager->AddRecord(ident, pConfigRecordInfo->GetName(), pConfigRecordInfo->GetStartData(), pConfigRecordInfo->GetTag(), pConfigRecordInfo->GetRows()); - - xRecord->SetPublic(pConfigRecordInfo->GetPublic()); - xRecord->SetPrivate(pConfigRecordInfo->GetPrivate()); - xRecord->SetSave(pConfigRecordInfo->GetSave()); - xRecord->SetCache(pConfigRecordInfo->GetCache()); - xRecord->SetUpload(pConfigRecordInfo->GetUpload()); - // pObject->AddRecordCallBack(pConfigRecordInfo->GetName(), this, &WorldModule::OnRecordCommonEvent); @@ -162,13 +148,13 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s { Vector3 vRelivePos = m_scene_->GetRelivePosition(sceneID, 0); - pObject->SetPropertyString(excel::IObject::ConfigID(), configIndex); - pObject->SetPropertyString(excel::IObject::ClassName(), className); - pObject->SetPropertyInt(excel::IObject::SceneID(), sceneID); - pObject->SetPropertyInt(excel::IObject::GroupID(), groupID); - pObject->SetPropertyVector3(excel::IObject::Position(), vRelivePos); + pObject->SetPropertyString(excel::Object::ConfigID(), configIndex); + pObject->SetPropertyString(excel::Object::ClassName(), className); + pObject->SetPropertyInt(excel::Object::SceneID(), sceneID); + pObject->SetPropertyInt(excel::Object::GroupID(), groupID); + pObject->SetPropertyVector3(excel::Object::Position(), vRelivePos); - pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Player::ThisName() ? true : false); + pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Object::ThisName() ? true : false); DoEvent(ident, className, pObject->GetState(), arg); } @@ -200,9 +186,9 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s std::shared_ptr pPropertyManager = pObject->GetPropertyManager(); for (int i = 0; i < arg.GetCount() - 1; i += 2) { const std::string &propertyName = arg.String(i); - if (excel::IObject::ConfigID() != propertyName && excel::IObject::ClassName() != propertyName && - excel::IObject::SceneID() != propertyName && excel::IObject::ID() != propertyName && - excel::IObject::GroupID() != propertyName) { + if (excel::Object::ConfigID() != propertyName && excel::Object::ClassName() != propertyName && + excel::Object::SceneID() != propertyName && excel::Object::ID() != propertyName && + excel::Object::GroupID() != propertyName) { std::shared_ptr pArgProperty = pPropertyManager->GetElement(propertyName); if (pArgProperty) { switch (pArgProperty->GetType()) { @@ -236,7 +222,7 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s stream << " config_name: " << configIndex; stream << " scene_id: " << sceneID; stream << " group_id: " << groupID; - stream << " position: " << pObject->GetPropertyVector3(excel::IObject::Position()).ToString(); + stream << " position: " << pObject->GetPropertyVector3(excel::Object::Position()).ToString(); LOG_INFO("%v", stream.str()); @@ -295,13 +281,6 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s std::shared_ptr xProperty = pPropertyManager->AddProperty(ident, pStaticConfigPropertyInfo->GetKey(), pStaticConfigPropertyInfo->GetType()); - xProperty->SetPublic(pStaticConfigPropertyInfo->GetPublic()); - xProperty->SetPrivate(pStaticConfigPropertyInfo->GetPrivate()); - xProperty->SetSave(pStaticConfigPropertyInfo->GetSave()); - xProperty->SetCache(pStaticConfigPropertyInfo->GetCache()); - xProperty->SetRef(pStaticConfigPropertyInfo->GetRef()); - xProperty->SetUpload(pStaticConfigPropertyInfo->GetUpload()); - pObject->AddPropertyCallBack(pStaticConfigPropertyInfo->GetKey(), this, &WorldModule::OnPropertyCommonEvent); pStaticConfigPropertyInfo = pStaticClassPropertyManager->Next(); @@ -312,12 +291,6 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s std::shared_ptr xRecord = pRecordManager->AddRecord(ident, pConfigRecordInfo->GetName(), pConfigRecordInfo->GetStartData(), pConfigRecordInfo->GetTag(), pConfigRecordInfo->GetRows()); - xRecord->SetPublic(pConfigRecordInfo->GetPublic()); - xRecord->SetPrivate(pConfigRecordInfo->GetPrivate()); - xRecord->SetSave(pConfigRecordInfo->GetSave()); - xRecord->SetCache(pConfigRecordInfo->GetCache()); - xRecord->SetUpload(pConfigRecordInfo->GetUpload()); - pObject->AddRecordCallBack(pConfigRecordInfo->GetName(), this, &WorldModule::OnRecordCommonEvent); pConfigRecordInfo = pStaticClassRecordManager->Next(); @@ -329,14 +302,14 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s { Vector3 vRelivePos = m_scene_->GetRelivePosition(sceneID, 0); - pObject->SetPropertyObject(excel::IObject::ID(), ident); - pObject->SetPropertyString(excel::IObject::ConfigID(), configIndex); - pObject->SetPropertyString(excel::IObject::ClassName(), className); - pObject->SetPropertyInt(excel::IObject::SceneID(), sceneID); - pObject->SetPropertyInt(excel::IObject::GroupID(), groupID); - pObject->SetPropertyVector3(excel::IObject::Position(), vRelivePos); + pObject->SetPropertyObject(excel::Object::ID(), ident); + pObject->SetPropertyString(excel::Object::ConfigID(), configIndex); + pObject->SetPropertyString(excel::Object::ClassName(), className); + pObject->SetPropertyInt(excel::Object::SceneID(), sceneID); + pObject->SetPropertyInt(excel::Object::GroupID(), groupID); + pObject->SetPropertyVector3(excel::Object::Position(), vRelivePos); - pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Player::ThisName() ? true : false); + pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Object::ThisName() ? true : false); DoEvent(ident, className, pObject->GetState(), arg); } @@ -365,8 +338,8 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s std::shared_ptr pPropertyManager = pObject->GetPropertyManager(); for (int i = 0; i < arg.GetCount() - 1; i += 2) { const std::string &propertyName = arg.String(i); - if (excel::IObject::ConfigID() != propertyName && excel::IObject::ClassName() != propertyName && excel::IObject::SceneID() != propertyName && - excel::IObject::ID() != propertyName && excel::IObject::GroupID() != propertyName) { + if (excel::Object::ConfigID() != propertyName && excel::Object::ClassName() != propertyName && excel::Object::SceneID() != propertyName && + excel::Object::ID() != propertyName && excel::Object::GroupID() != propertyName) { std::shared_ptr pArgProperty = pPropertyManager->GetElement(propertyName); if (pArgProperty) { switch (pArgProperty->GetType()) { @@ -400,7 +373,7 @@ std::shared_ptr WorldModule::CreateObject(const Guid &self, const int s stream << " config_name: " << configIndex; stream << " scene_id: " << sceneID; stream << " group_id: " << groupID; - stream << " position: " << pObject->GetPropertyVector3(excel::IObject::Position()).ToString(); + stream << " position: " << pObject->GetPropertyVector3(excel::Object::Position()).ToString(); // m_log_->LogInfo(stream); @@ -448,20 +421,20 @@ bool WorldModule::DestroyObject(const Guid &self) { return DestroySelf(self); } - const int sceneID = GetPropertyInt32(self, excel::IObject::SceneID()); - const int groupID = GetPropertyInt32(self, excel::IObject::GroupID()); + const int sceneID = GetPropertyInt32(self, excel::Object::SceneID()); + const int groupID = GetPropertyInt32(self, excel::Object::GroupID()); std::shared_ptr pContainerInfo = m_scene_->GetElement(sceneID); if (pContainerInfo) { - const std::string &className = GetPropertyString(self, excel::IObject::ClassName()); - if (className == excel::Player::ThisName()) { + const std::string &className = GetPropertyString(self, excel::Object::ClassName()); + if (className == excel::Object::ThisName()) { m_scene_->LeaveSceneGroup(self); } DoEvent(self, className, COE_BEFOREDESTROY, DataList::Empty()); DoEvent(self, className, COE_DESTROY, DataList::Empty()); - if (className != excel::Player::ThisName()) { + if (className != excel::Object::ThisName()) { pContainerInfo->RemoveObjectFromGroup(groupID, self, false); } @@ -1161,7 +1134,7 @@ bool WorldModule::GetGroupObjectList(const int sceneID, const int groupID, const continue; } - if (this->GetPropertyString(xID, excel::IObject::ClassName()) == className && xID != noSelf) { + if (this->GetPropertyString(xID, excel::Object::ClassName()) == className && xID != noSelf) { list.AddObject(xID); } } @@ -1194,8 +1167,8 @@ bool WorldModule::LogInfo(const Guid ident) { std::shared_ptr pObject = GetObject(ident); if (pObject) { - int sceneID = GetPropertyInt32(ident, excel::IObject::SceneID()); - int groupID = GetPropertyInt32(ident, excel::IObject::GroupID()); + int sceneID = GetPropertyInt32(ident, excel::Object::SceneID()); + int groupID = GetPropertyInt32(ident, excel::Object::GroupID()); LOG_INFO("Guid<%v> SceneID<%v>", ident.ToString(), sceneID); } else { LOG_ERROR("Guid<%v> There is no object", ident.ToString()); @@ -1218,7 +1191,7 @@ int WorldModule::OnPropertyCommonEvent(const Guid &self, const std::string &prop pFun->operator()(self, propertyName, oldVar, newVar, reason); } - const std::string &className = xObject->GetPropertyString(excel::IObject::ClassName()); + const std::string &className = xObject->GetPropertyString(excel::Object::ClassName()); std::map>::iterator itClass = mtClassPropertyCallBackList.find(className); if (itClass != mtClassPropertyCallBackList.end()) { std::list::iterator itList = itClass->second.begin(); @@ -1331,7 +1304,7 @@ int WorldModule::OnRecordCommonEvent(const Guid &self, const RECORD_EVENT_DATA & } } - const std::string &className = xObject->GetPropertyString(excel::IObject::ClassName()); + const std::string &className = xObject->GetPropertyString(excel::Object::ClassName()); std::map>::iterator itClass = mtClassRecordCallBackList.find(className); if (itClass != mtClassRecordCallBackList.end()) { std::list::iterator itList = itClass->second.begin(); diff --git a/src/tools/sqkctl/CMakeLists.txt b/src/tools/sqkctl/CMakeLists.txt index fe472712..f6879944 100644 --- a/src/tools/sqkctl/CMakeLists.txt +++ b/src/tools/sqkctl/CMakeLists.txt @@ -121,6 +121,10 @@ set_target_properties( ${proName} PROPERTIES ) endmacro(SquickOut) +if (UNIX) + SET ( CMAKE_CXX_FLAGS "-g" ) +endif() + SquickOut(${ProjectName} ${ProjectName} ${SolutionDir}/tools/bin ${ProjectName}) add_definitions( -D_CRT_SECURE_NO_WARNINGS diff --git a/src/tools/sqkctl/excel/config_generator.cc b/src/tools/sqkctl/excel/config_generator.cc index b6b06598..f046c73a 100644 --- a/src/tools/sqkctl/excel/config_generator.cc +++ b/src/tools/sqkctl/excel/config_generator.cc @@ -15,12 +15,8 @@ ConfigGenerator::ConfigGenerator(const std::string &excelPath, const std::string mxGenerators.push_back(new CPPGenerator(excelPath, outPath)); mxGenerators.push_back(new CSGenerator(excelPath, outPath)); mxGenerators.push_back(new IniGenerator(excelPath, outPath)); - mxGenerators.push_back(new JAVAGenerator(excelPath, outPath)); mxGenerators.push_back(new LogicClassGenerator(excelPath, outPath)); - mxGenerators.push_back(new PBGenerator(excelPath, outPath)); - mxGenerators.push_back(new SQLGenerator(excelPath, outPath)); mxGenerators.push_back(new StructGenerator(excelPath, outPath)); - mxGenerators.push_back(new TSGenerator(excelPath, outPath)); mxGenerators.push_back(new LuaGenerator(excelPath, outPath)); strExcelIniPath = excelPath; diff --git a/src/tools/sqkctl/excel/config_generator.h b/src/tools/sqkctl/excel/config_generator.h index d4396c38..36c3ab8c 100644 --- a/src/tools/sqkctl/excel/config_generator.h +++ b/src/tools/sqkctl/excel/config_generator.h @@ -3,15 +3,11 @@ #include "cpp_generator.h" #include "cs_generator.h" #include "ini_generator.h" -#include "java_generator.h" #include "logic_class_generator.h" #include "lua_generator.h" #include "mini_excel_reader.h" -#include "pb_generator.h" -#include "sql_generator.h" #include "struct_generator.h" #include "third_party/common/lexical_cast.hpp" -#include "ts_generator.h" #include namespace sqkctl { @@ -50,9 +46,10 @@ class ConfigGenerator { private: bool bConvertIntoUTF8 = false; - const int nPropertyHeight = 10; // property line - const int nRecordHeight = 13; // record line - const int nRecordDescHeight = 9; // record line + // Excel base header attr line define + const int nPropertyHeight = 3; // property line + const int nRecordHeight = 6; // record line + const int nRecordDescHeight = 2; // record line std::string outPath; std::string strExcelIniPath; // = "../excel/"; diff --git a/src/tools/sqkctl/excel/java_generator.h b/src/tools/sqkctl/excel/java_generator.h deleted file mode 100644 index df5b8b2a..00000000 --- a/src/tools/sqkctl/excel/java_generator.h +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class JAVAGenerator : public IGenerator { - public: - JAVAGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { - - FILE *javaWriter = fopen((outPath + "/excel/Excel.java").c_str(), "w"); - - std::string strFileHead = "// -------------------------------------------------------------------------\n"; - strFileHead = strFileHead + "// @FileName : Excel.java\n" + "// @Author : I0gan\n" + - "// @Module : Excel\n" + "// -------------------------------------------------------------------------\n\n" + - "package Excel;\n"; - - fwrite(strFileHead.c_str(), strFileHead.length(), 1, javaWriter); - ///////////////////////////////////////////////////// - - ClassData *pBaseObject = classData.at("IObject"); - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - if (pClassDta->beIncluded || pClassDta->beParted || className == "Include") { - continue; - } - - // cs - std::string strPropertyInfo; - - strPropertyInfo += "\tpublic class " + className + "\n\t{\n"; - strPropertyInfo += "\t\t//Class name\n\t"; - strPropertyInfo += "\tpublic static final String ThisName = \"" + className + "\";\n"; - - if (className != "IObject") { - // add base class properties - strPropertyInfo += "\t\t// IObject\n"; - - for (std::map::iterator itProperty = pBaseObject->xStructData.xPropertyList.begin(); - itProperty != pBaseObject->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static final String " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - } - - strPropertyInfo += "\t\t// Property\n"; - for (std::map::iterator itProperty = pClassDta->xStructData.xPropertyList.begin(); - itProperty != pClassDta->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static final String " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - - fwrite(strPropertyInfo.c_str(), strPropertyInfo.length(), 1, javaWriter); - - // record - std::string strRecordInfo = ""; - strRecordInfo += "\t\t// Record\n"; - - for (std::map::iterator itRecord = pClassDta->xStructData.xRecordList.begin(); - itRecord != pClassDta->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *pClassRecord = itRecord->second; - - std::cout << "save for java ---> " << className << "::" << recordName << std::endl; - - strRecordInfo += "\t\tpublic class " + recordName + "\n\t\t{\n"; - strRecordInfo += "\t\t\t//Class name\n\t"; - strRecordInfo += "\t\tpublic static final String ThisName = \"" + recordName + "\";\n"; - - // col - for (int i = 0; i < pClassRecord->colList.size(); ++i) { - for (std::map::iterator itCol = pClassRecord->colList.begin(); - itCol != pClassRecord->colList.end(); ++itCol) { - const std::string &colTag = itCol->first; - ClassRecord::RecordColDesc *pRecordColDesc = itCol->second; - - if (pRecordColDesc->index == i) { - strRecordInfo += - "\t\t\tpublic static final int " + colTag + " = " + std::to_string(pRecordColDesc->index) + ";//" + pRecordColDesc->type + "\n"; - } - } - } - - strRecordInfo += "\n\t\t}\n"; - } - fwrite(strRecordInfo.c_str(), strRecordInfo.length(), 1, javaWriter); - - std::string strHppEnumInfo = ""; - - std::string strClassEnd; - strClassEnd += "\n\t}\n"; - - fwrite(strClassEnd.c_str(), strClassEnd.length(), 1, javaWriter); - } - fclose(javaWriter); - - return false; - } -}; -} // namespace sqkctl diff --git a/src/tools/sqkctl/excel/logic_class_generator.h b/src/tools/sqkctl/excel/logic_class_generator.h index 7ae87842..95c0f52e 100644 --- a/src/tools/sqkctl/excel/logic_class_generator.h +++ b/src/tools/sqkctl/excel/logic_class_generator.h @@ -8,7 +8,7 @@ class LogicClassGenerator : public IGenerator { LogicClassGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } virtual bool Generate(const std::map &classData) override { - std::string fileName = strXMLStructPath + "logic_class.xml"; + std::string fileName = strXMLStructPath + "Root.xml"; FILE *iniWriter = fopen(fileName.c_str(), "w"); diff --git a/src/tools/sqkctl/excel/mini_excel_reader.cc b/src/tools/sqkctl/excel/mini_excel_reader.cc index 77b5d460..4bac4bc3 100644 --- a/src/tools/sqkctl/excel/mini_excel_reader.cc +++ b/src/tools/sqkctl/excel/mini_excel_reader.cc @@ -41,7 +41,7 @@ bool Zip::open(const char *file) { char szCurrentFileName[PATH_MAX]; unz_file_info64 fileInfo; - int err = unzGoToNextFile2(_zipFile, &fileInfo, szCurrentFileName, sizeof(szCurrentFileName) - 1, nullptr, 0, nullptr, 0); + int err = unzGoToFirstFile2(_zipFile, &fileInfo, szCurrentFileName, sizeof(szCurrentFileName) - 1, nullptr, 0, nullptr, 0); while (err == UNZ_OK) { unz_file_pos posInfo; if (unzGetFilePos(_zipFile, &posInfo) == UNZ_OK) { @@ -52,7 +52,9 @@ bool Zip::open(const char *file) { entry.uncompressed_size = (uLong)fileInfo.uncompressed_size; _files[currentFileName] = entry; } + // std::cout << file << " loading: " << szCurrentFileName << " " << err << std::endl; err = unzGoToNextFile2(_zipFile, &fileInfo, szCurrentFileName, sizeof(szCurrentFileName) - 1, nullptr, 0, nullptr, 0); + } return true; diff --git a/src/tools/sqkctl/excel/pb_generator.h b/src/tools/sqkctl/excel/pb_generator.h deleted file mode 100644 index 09afe91b..00000000 --- a/src/tools/sqkctl/excel/pb_generator.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class PBGenerator : public IGenerator { - public: - PBGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { return false; } -}; -} // namespace sqkctl diff --git a/src/tools/sqkctl/excel/sql_generator.h b/src/tools/sqkctl/excel/sql_generator.h deleted file mode 100644 index a7676df5..00000000 --- a/src/tools/sqkctl/excel/sql_generator.h +++ /dev/null @@ -1,124 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class SQLGenerator : public IGenerator { - - public: - SQLGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { - // 1 class.sql - std::string fileName = outPath + "/excel/server.sql"; - - FILE *iniWriter = fopen(fileName.c_str(), "w"); - - std::string strElementData; - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - if (pClassDta->beIncluded || pClassDta->beParted || className == "Include") { - continue; - } - - strElementData += "CREATE TABLE IF NOT EXISTS " + pClassDta->xStructData.className + " ("; - strElementData += " `ID` varchar(128) NOT NULL,"; - strElementData += " PRIMARY KEY (`ID`)"; - strElementData += " ) ENGINE=InnoDB DEFAULT CHARSET=utf8; \n"; - } - - // 2 fields - // ALTER TABLE `Buff` ADD `EffectType` bigint(11) DEFAULT '0' COMMENT '影响属性类型(效果类型) 生命,法力(可组合,叠加)'; - // 2.1) property - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - for (std::map::iterator itProperty = pClassDta->xStructData.xPropertyList.begin(); - itProperty != pClassDta->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *xPropertyData = itProperty->second; - - std::string strType; - std::string strSave; - std::string strCache; - std::string strDesc; - for (std::map::iterator itDesc = xPropertyData->descList.begin(); itDesc != xPropertyData->descList.end(); ++itDesc) { - const std::string &strKey = itDesc->first; - const std::string &value = itDesc->second; - if (strKey == "Type") { - strType = value; - } else if (strKey == "Save") { - strSave = value; - } else if (strKey == "Cache") { - strCache = value; - } else if (strKey == "Desc") { - strDesc = value; - } - } - - if (strSave == "1" || strCache == "1") { - std::string strAlter = "\nALTER TABLE `" + className + "` ADD `" + propertyName + "`"; - // ALTER TABLE `Buff` ADD `EffectType` bigint(11) DEFAULT '0' COMMENT '影响属性类型(效果类型) 生命,法力(可组合,叠加)'; - if (strType == "int") { - strAlter += " bigint(11) DEFAULT '0'"; - } else if (strType == "string") { - strAlter += " text COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } else if (strType == "float") { - strAlter += " double DEFAULT '0.0'"; - } else if (strType == "object") { - strAlter += " varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } else if (strType == "vector2") { - strAlter += " varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } else if (strType == "vector3") { - strAlter += " varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } - - strAlter += " COMMENT '" + strDesc + "';"; - - strElementData += strAlter; - } - } - - // 2.2) record - for (std::map::iterator itRecord = pClassDta->xStructData.xRecordList.begin(); - itRecord != pClassDta->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *xRecordData = itRecord->second; - - std::string strType; - std::string strSave; - std::string strCache; - std::string strDesc; - for (std::map::iterator itDesc = xRecordData->descList.begin(); itDesc != xRecordData->descList.end(); ++itDesc) { - const std::string &strKey = itDesc->first; - const std::string &value = itDesc->second; - if (strKey == "Type") { - strType = value; - } else if (strKey == "Save") { - strSave = value; - } else if (strKey == "Cache") { - strCache = value; - } else if (strKey == "Desc") { - strDesc = value; - } - } - - if (strSave == "1" || strCache == "1") { - std::string strAlter = "\nALTER TABLE `" + className + "` ADD `" + recordName + "`"; - strAlter += " text COLLATE utf8mb4_unicode_ci DEFAULT ''"; - strAlter += " COMMENT '" + strDesc + "';"; - - strElementData += strAlter; - } - } - } - - fwrite(strElementData.c_str(), strElementData.length(), 1, iniWriter); - fclose(iniWriter); - - return true; - } -}; -} // namespace sqkctl diff --git a/src/tools/sqkctl/excel/ts_generator.h b/src/tools/sqkctl/excel/ts_generator.h deleted file mode 100644 index 405154b5..00000000 --- a/src/tools/sqkctl/excel/ts_generator.h +++ /dev/null @@ -1,167 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class TSGenerator : public IGenerator { - public: - TSGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { - - FILE *csWriter = fopen((outPath + "/excel/excel.ts").c_str(), "w"); - - std::string strFileHead = "// -------------------------------------------------------------------------\n"; - strFileHead = strFileHead + "// @FileName : excel.ts\n" + "// @Author : I0gan\n" + - "// @Module : Excel\n" + "// -------------------------------------------------------------------------\n\n"; - fwrite(strFileHead.c_str(), strFileHead.length(), 1, csWriter); - - ClassData *pBaseObject = classData.at("IObject"); - std::string allClassNames = "export const Excel={\n\t\t"; - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - if (pClassDta->beIncluded || pClassDta->beParted || className == "Include") { - continue; - } - - // ts - std::string strPropertyInfo; - if (it != classData.begin()) { - allClassNames += ','; - } - allClassNames += className; - - strPropertyInfo += "\tclass " + className + "\n\t{\n"; - strPropertyInfo += "\t\t//Class name\n\t"; - strPropertyInfo += "\tpublic static ThisName = \"" + className + "\";\n"; - if (className != "IObject") { - // add base class properties - strPropertyInfo += "\t\t// IObject\n"; - - for (std::map::iterator itProperty = pBaseObject->xStructData.xPropertyList.begin(); - itProperty != pBaseObject->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - } - - strPropertyInfo += "\t\t// Property\n"; - for (std::map::iterator itProperty = pClassDta->xStructData.xPropertyList.begin(); - itProperty != pClassDta->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - - // include property, come from - - for (std::string item : pClassDta->includes) { - auto includeClass = classData.at(item); - - strPropertyInfo += "\t\t// Include Property, come from " + includeClass->xStructData.className + " \n"; - - for (std::map::iterator itProperty = includeClass->xStructData.xPropertyList.begin(); - itProperty != includeClass->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - } - - fwrite(strPropertyInfo.c_str(), strPropertyInfo.length(), 1, csWriter); - - // record - std::string strRecordInfo = ""; - strRecordInfo += "\t\t// Record\n"; - - for (std::map::iterator itRecord = pClassDta->xStructData.xRecordList.begin(); - itRecord != pClassDta->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *pClassRecord = itRecord->second; - - std::cout << "save for ts ---> " << className << "::" << recordName << std::endl; - - strRecordInfo += "\t\tpublic static " + recordName + " = \n\t\t{\n"; - strRecordInfo += "\t\t\t//Class name\n\t"; - strRecordInfo += "\t\t\"ThisName\":\"" + recordName + "\",\n"; - - // col - for (int i = 0; i < pClassRecord->colList.size(); ++i) { - for (std::map::iterator itCol = pClassRecord->colList.begin(); - itCol != pClassRecord->colList.end(); ++itCol) { - - const std::string &colTag = itCol->first; - ClassRecord::RecordColDesc *pRecordColDesc = itCol->second; - - if (pRecordColDesc->index == i) { - if (i != 0) { - strRecordInfo += ",\n"; - } - strRecordInfo += "\t\t\t\"" + colTag + "\":" + std::to_string(pRecordColDesc->index); - } - } - } - - strRecordInfo += "\n\t\t}\n"; - } - - for (std::string item : pClassDta->includes) { - auto includeClass = classData.at(item); - - strRecordInfo += "\t\t// Include Record, come from " + includeClass->xStructData.className + " \n"; - - for (std::map::iterator itRecord = includeClass->xStructData.xRecordList.begin(); - itRecord != includeClass->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *pClassRecord = itRecord->second; - - strRecordInfo += "\t\tpublic static " + recordName + " = \n\t\t{\n"; - strRecordInfo += "\t\t\t//Class name\n\t"; - strRecordInfo += "\t\t\"ThisName\":\"" + recordName + "\",\n"; - - // col - for (int i = 0; i < pClassRecord->colList.size(); ++i) { - for (std::map::iterator itCol = pClassRecord->colList.begin(); - itCol != pClassRecord->colList.end(); ++itCol) { - - const std::string &colTag = itCol->first; - ClassRecord::RecordColDesc *pRecordColDesc = itCol->second; - - if (pRecordColDesc->index == i) { - if (i != 0) { - strRecordInfo += ",\n"; - } - strRecordInfo += "\t\t\t\"" + colTag + "\":" + std::to_string(pRecordColDesc->index); - } - } - } - - strRecordInfo += "\n\t\t}\n"; - } - } - - fwrite(strRecordInfo.c_str(), strRecordInfo.length(), 1, csWriter); - - std::string strHppEnumInfo = ""; - - std::string strClassEnd; - strClassEnd += "\n\t}\n"; - - fwrite(strClassEnd.c_str(), strClassEnd.length(), 1, csWriter); - } - allClassNames += "}\n"; - fwrite(allClassNames.c_str(), allClassNames.length(), 1, csWriter); - fclose(csWriter); - - return false; - } -}; -} // namespace sqkctl diff --git a/tools/binary_strip.sh b/tools/binary_strip.sh new file mode 100755 index 00000000..ee53b907 --- /dev/null +++ b/tools/binary_strip.sh @@ -0,0 +1,4 @@ +#! /bin/bash + +cd ../bin +find . -type f -executable -exec strip {} \; diff --git a/tools/generate_k8s_deploy.sh b/tools/generate_k8s_deploy.sh new file mode 100755 index 00000000..623e8548 --- /dev/null +++ b/tools/generate_k8s_deploy.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +# build image +bash ../docker/build_image.sh + + +