Implemented: Additional Map Data, part 2

DeletedUser895

Guest
Since the original thread (where I originally posted this reply...) is marked as Implemented, I thought it would be best to create a new thread to revisit this, instead of just leaving my comments in the old one.

It was previously requested (by dalesmckay) that extra data be added to the TWMap Javascript Object to keep track of the last AttackInfo. This has apparently been implemented in the game, but has not completely fixed the issue I believe dalesmckay was hoping to have fixed.

My reply to the thread and idea request is s follows...


The thread says this has been implemented, and I just wanted to make sure this was the case.

I see both TWMap.villages[].extra and TWMap.allies[] when looking at the TWMap object, but I believe the underlying problem suggested in the first post hasn't been fixed yet: the information in TWMap.villages[].extra seems to only appear after mousing over the village in question. This is exactly how the map worked prior (only, the information was put in TWMap.popup._cache[villageid] and not TWMap.villages[villagecoordinates].extra) and doesn't fix that a script which requires the data (without having to force the AJAX calls systematically, or by having the user mouse over each and every village) cannot effectively be made following many servers' rules on scripts and loading pages in the background. (not to mention, ~70 AJAX calls on an average 15x15 map probably isn't optimal for the servers)

In my pursuit of recreating a "map overlay" script with similar functionality to pre-version 7 scripts, I have tried slightly modifying the TWMap.map.handler.spawnSection function to draw a small box (including how long ago said village was attacked) over each village with extra (and extra.attack) information, followed by calling the TWMap.map.reload function (to let the spawnSector function run with its new code), and finally, tying the TWMap.map.reload function to $(document).ajaxStop so it is called every time an ajax request finishes: the only way to currently have the overlay work requires systematically forcing an AJAX request for every village's extra object, or having the user mouse over each and every village.

It is my hope that the above information is enough to help explain what it is the scripters in this thread hope to do, and what problem(s) stand in the way of doing so effectively.

Thanks for all your time and effort developing this game, we greatly appreciate it.

-LastApparatus
 

DeletedUser

Guest
My original fix was intended to be extremely simple for the TW Developers to implement.

The TWMap.allies Object was implemented correctly.

However, the TWMap.villages needs to be implemented the same way.

eg.

If the village data has not been populated:
  • Run the SQL query to fetch the TWMap.Villages[xxxxxx] data
  • Populate the TWMap.Villages[xxxxxx] Object
  • If it is a Premium Account, also run an SQL query to fetch the attack data for TWMap.Villages[xxxxxx]
  • Append the attack data to the TWMap.Villages[xxxxxx] Object

A non-premium TWMap.Villages[xxxxxx] Object would look like this:
Code:
TWMap.villages[coord_minus_pipe_char]
	id:string
	img:number
	name:string
	points:string
	owner:string
	mood:string
	bonus:undefined
	attackInfo:object	- null

A Premium TWMap.Villages[xxxxxx] Object would look like this:
Code:
TWMap.villages[coord_minus_pipe_char]
	id:string
	img:number
	name:string
	points:string
	owner:string
	mood:string
	bonus:undefined
	attackInfo:object
		reportDateTime:string	- Dec 19,2010 01:39 o'clock
		status:string		- dots/blue.png
		loot:string		- max_loot/1.png

I don't see any need for the TWMap.scriptMode Attribute with this.

The Data should be fetched when the Village Data is being fetched... NOT when moving the mouse over a village.
it must not require additional AJAX calls.

Hope this makes sense to the TW Developers.

regards
 

DeletedUser

Guest
The scriptMode flag does exactly that - it populates the villages object with the 'extra' block (which contains the popup information, including attack).

If scriptMode is set the popup information will be requested automatically as soon as the villages become visible.

TWMap.mapHandler.loadSector includes this routine:
Code:
if (TWMap.scriptMode)
	TWMap.popup.loadVillage(village_ids.join(','));

The additional information will not be available at once, but rather be fetched via AJAX. You do not need to hover your mouse over the village to achieve that. The only requirement is that the flag has to be set when a sector is loaded.

Here is an example of this feature using the Google Chrome developer tools:
ds_scriptmode.png


All you have to do is set the scriptFlag setting before the intial sector loading is complete.


Technical background for the scriptMode flag: Basic sector informations (villages, players, allies) do not depend on a specific player and hence can be cached globally. Attack information, however, involve player-specific database queries. To save resources these information are only loaded on demand (hovering the village dynamically requests the popup content).

The scriptMode flag is sort of a hack to request the popups automatically and put the information into the TWMap.villages[] object. Including attack information in the basic sector block would involve major changes in the general map structure and significantly increased server load.
 

DeletedUser895

Guest
After a bit more messing around, I've realized that running TWMap.map.reload() is apparently not enough to make up for me not setting TWMap.scriptMode to true in time, and if I start the map at 500,500, run my script, and then drag to my village (thus forcing the sector to load) it does work just as you described. My apologies, and thank you for both your time and effort. One last thing: can you make any suggestions on how I could force any visible sectors to reload?
 

DeletedUser

Guest
[SPOIL]The scriptMode flag does exactly that - it populates the villages object with the 'extra' block (which contains the popup information, including attack).

If scriptMode is set the popup information will be requested automatically as soon as the villages become visible.

TWMap.mapHandler.loadSector includes this routine:
Code:
if (TWMap.scriptMode)
	TWMap.popup.loadVillage(village_ids.join(','));

The additional information will not be available at once, but rather be fetched via AJAX. You do not need to hover your mouse over the village to achieve that. The only requirement is that the flag has to be set when a sector is loaded.

Here is an example of this feature using the Google Chrome developer tools:
ds_scriptmode.png


All you have to do is set the scriptFlag setting before the intial sector loading is complete.


Technical background for the scriptMode flag: Basic sector informations (villages, players, allies) do not depend on a specific player and hence can be cached globally. Attack information, however, involve player-specific database queries. To save resources these information are only loaded on demand (hovering the village dynamically requests the popup content).

The scriptMode flag is sort of a hack to request the popups automatically and put the information into the TWMap.villages[] object. Including attack information in the basic sector block would involve major changes in the general map structure and significantly increased server load.[/SPOIL]

Thanks for the answer.

I have not had a chance to personally investigate this properly yet.
I was trying to clarify my original intention.

I'll hopefully be able to have a look some time in the next week.
 

DeletedUser895

Guest
I would like to say thanks again for this, and my apologies once more for suggesting it wasn't fixed properly the first time. Clearly, I didn't investigate enough and jumped to an assumption too early. As to my previous question of forcing visible sectors to reload, I've found my answer. Thanks again for all your time and effort put forth into both, replying to me, and developing this game.
 
Top