Skip to content

Commit

Permalink
Fix misc bugs
Browse files Browse the repository at this point in the history
 - Add gettimeout and settimeout to socket
 - Fix component namespace issue
  • Loading branch information
arwassa committed Aug 12, 2020
1 parent 2005b9b commit 2f5cdd7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 43 deletions.
2 changes: 1 addition & 1 deletion extra/uuid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end
-- uuid.seed()
-- print("here's a new uuid: ",uuid())
function M.seed()
if package.loaded["socket"] and package.loaded["socket"].gettime then
if package.loaded["sockdl"] and package.loaded["sockdl"].gettime then
return M.randomseed(package.loaded["socket"].gettime()*10000)
else
return M.randomseed(os.time())
Expand Down
6 changes: 3 additions & 3 deletions src/bzpre/bzext.moon
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ craftStates = {
}


getAppInfo = (id) ->
getAppInfo = (id="301650") ->
if not _appinfo
_appinfo = bzpre.getAppInfo(id)
return _appinfo

getUserId = () ->
getAppInfo()\gmatch('"LastOwner"%s*"(%d+)"')()
getUserId = (id) ->
getAppInfo(id)\gmatch('"LastOwner"%s*"(%d+)"')()


-- producer specific functions
Expand Down
12 changes: 10 additions & 2 deletions src/bzpre/bztt.moon
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ class ReadBuffer
class TcpSocket
new: (sock=socket.tcp(), timeout=0.005) =>
@sock = sock
@sock\settimeout(timeout)
@timeoutValue = 0
@settimeout(timeout)
@mode = "NONE"
@socketSubject = Subject.create()
@closed = false
@sock\setoption("keepalive", true)

@connect: (...) =>
sock = socket.tcp()
res, err = sock\connect(...)
Expand All @@ -167,6 +168,13 @@ class TcpSocket
return nil
return TcpSocket(sock)

settimeout: (v) =>
@sock\settimeout(v)
@timeoutValue = v

gettimeout: () =>
return @timeoutValue


getstats: () =>
return @sock\getstats()
Expand Down
42 changes: 6 additions & 36 deletions src/ecs/bzcomp.moon
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,7 @@ class ParticleEmitterComponent extends Component



namespace("ecs.component",
BzHandleComponent,
BzBuildingComponent,
BzVehicleComponent,
BzPlayerComponent,
BzPersonComponent,
BzRecyclerComponent,
BzFactoryComponent,
BzArmoryComponent,
BzHowitzerComponent,
BzWalkerComponent,
BzConstructorComponent,
BzWingmanComponent,
BzGuntowerComponent,
BzTurretComponent,
BzScavengerComponent,
BzTugComponent,
BzMinelayerComponent,
BzHangarComponent,
BzSupplydepotComponent,
BzSiloComponent,
BzCommtowerComponent,
BzPortalComponent,
BzPowerplantComponent,
BzSignComponent,
BzArtifactComponent,
BzStructureComponent,
BzAnimstructureComponent,
BzBarracksComponent,
ParticleEmitterComponent,
BzLocalComponent,
BzRemoteComponent
)


return {
components = {
:BzHandleComponent,
:BzBuildingComponent,
:BzVehicleComponent,
Expand Down Expand Up @@ -150,3 +115,8 @@ return {
:BzRemoteComponent,
:PositionComponent
}

for i, v in pairs(components)
namespace("ecs.component", v)

return components
2 changes: 1 addition & 1 deletion src/math/exmath.moon
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Area
@path = path
@handles = {}
@enabled = false
--Calculate center and radius
--Calculate center and radius
@_bounding()
--register everyone that is inside

Expand Down

0 comments on commit 2f5cdd7

Please sign in to comment.